Auto-stacking fails when `skip_previous` is `True`
I just setup an immich stack with an auto-stacking sidecar container, but the auto-stacking fails if skip_previous is set to True:
immich-auto-stack-1 | Traceback (most recent call last):
immich-auto-stack-1 | File "/script/immich_auto_stack.py", line 220, in <module>
immich-auto-stack-1 | main()
immich-auto-stack-1 | File "/script/immich_auto_stack.py", line 195, in main
immich-auto-stack-1 | children_id = [x['id'] for x in stack[1:] if x['stackCount'] == None ]
immich-auto-stack-1 | ~^^^^^^^^^^^^^^
immich-auto-stack-1 | KeyError: 'stackCount'
I dont know whether stackCount is something that is supposed to come from the immich API or it is some refactoring leftover, but in any case, it fails with the latest immich version
Could you find out which picture causes this error and provide the API response for it?
stackCount is part of the API response. It should be there always. And there is no deprecation notice.
I'll catch it but I really want to know what could have caused it.
Could you find out which picture causes this error and provide the API response for it?
stackCount is part of the API response. It should be there always. And there is no deprecation notice.
I'll catch it but I really want to know what could have caused it.
Thanks for the quick response. I ran couple of tests and there really isn't a stackCount field in the API response. I just started with immich so I might be missing something very obvious tho.
Here is the content of x, which should be what the API is returning:
{'id': '397eb2b2-7b3c-4862-a60c-8088f1e820ae', 'deviceAssetId': 'PXL_20240707_084051104.jpg', 'ownerId': '58a7d074-c1d4-4893-bd50-ab0648527566', 'deviceId': 'Library Import', 'libraryId': '1625a8c0-b36c-4753-a2cc-253357fb6b9d', 'type': 'IMAGE', 'originalPath': '/mnt/data/external/2024/2024.07.03-04 - Tirana/PXL_20240707_084051104.jpg', 'originalFileName': 'PXL_20240707_084051104.jpg', 'originalMimeType': 'image/jpeg', 'thumbhash': 'JMYFNQiZZqWYqGc3hp4I13dwegen', 'fileCreatedAt': '2024-07-07T08:40:51.104Z', 'fileModifiedAt': '2024-08-31T00:54:28.702Z', 'localDateTime': '2024-07-07T10:40:51.104Z', 'updatedAt': '2024-08-31T03:46:01.175Z', 'isFavorite': False, 'isArchived': False, 'isTrashed': False, 'duration': '0:00:00.00000', 'livePhotoVideoId': None, 'people': [], 'checksum': 'SrxPVDHHup7Rik8bBgQZRD2+Bh4=', 'isOffline': False, 'hasMetadata': True, 'duplicateId': None, 'resized': True}
I also ran a quick test and it seems none of the assets have this property:
immich = Immich(api_url, api_key)
assets = immich.fetchAssets()
print(any(a for a in assets if 'stackCount' in a))
>>> False
I think it's another case of poorly documented changes to the stacks functionality. I updated to the latest v1.113.0. The API response differs from the one in the official API docs for the latest version.
But the weird part is that I still have a stack property in my response, even if it's null, while you are missing it altogether.
I'll push a potential fix for it but first I want to see what they say in the docs. The stacks changes are quite big.
Alright, no pressure. Thanks for looking into this issue!
Keep an eye on the API responses. Maybe your library uses an old schema? Maybe after an update or two, or even a rescan, the schema will match the current version? Dunno, just thinking in writing.
Ще го оправим 😄
I also ran a quick test and it seems none of the assets have this property:
immich = Immich(api_url, api_key) assets = immich.fetchAssets() print(any(a for a in assets if 'stackCount' in a)) >>> False
Just as another data point, I am also seeing this on my instance.
Yup. Also, they have updated the API with the proper schema and docs. There is a whole new Stacks endpoint. I'll go through the changes as soon as I can and implement them.
Still getting this error.
Logs:
/script/immich_auto_stack.py
2024-11-01 14:05:40,814 - INFO - ============== INITIALIZING ==============
2024-11-01 14:05:40,815 - INFO - ⬇️ Fetching assets:
2024-11-01 14:05:40,815 - INFO - Page size: 1000
2024-11-01 14:05:51,977 - INFO - Pages: None
2024-11-01 14:05:51,977 - INFO - Assets: 13197
Traceback (most recent call last):
File "/script/immich_auto_stack.py", line 251, in
I'm also having this issue, is there a fix for this?
#13 works for me
Change line 225
children_id = [x['id'] for x in stack[1:] if x['stackCount'] == None ]
to
children_id = [x['id'] for x in stack[1:] if x.get('stackCount') is None ]