fix: decode Immich v3 numeric asset duration (#69)#71
Merged
Conversation
Immich v3 serialises asset `duration` as a number of milliseconds (and null) instead of a "0:00:00.000000" string, aborting every asset fetch with an unmarshal error. Add a Duration type that accepts a JSON string, number, or null; the "duration" extractor keeps returning a plain string.
Owner
|
Thanks for the PR! I was working on it but this looks good! I will just need to upgrade my instance to do production-like tests and if this is all good I merge and deploy tomorrow! |
Majorfi
added a commit
that referenced
this pull request
Jul 3, 2026
…ency Every other type in pkg/utils/types.go uses the T-prefix convention (TAsset, TStack, TDelta, TExifInfo, ...); the duration type added in #71 was the only one without it. The field name and JSON tag are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #69.
Immich v3 changed the asset
durationfield from a string ("0:00:00.000000") to a number of milliseconds (ornull), so decoding it into a Gostringaborts every fetch:This hits the default
IMAGE-only search too — animated GIFs areIMAGE-type but report a numeric duration on v3.Change: add a
Durationtype (underlyingstring) whoseUnmarshalJSONaccepts a string (v2), a number (v3), or null;TAsset.Durationuses it and the"duration"extractor returnsstring(a.Duration). Stdlib only, no new deps. v2 string values are stored verbatim; v3 numbers keep the literal ms token.Test plan: new unit tests prove
durationdecodes from both the v2 string and the v3 number form (plus null) —pkg/utils/types_test.go,pkg/stacker/duration_extractor_test.go.go test ./...and-racepass. Verified against a live Immich v3.0.0 instance: aborts before, full clean pass after.