Skip to content

fix: decode Immich v3 numeric asset duration (#69)#71

Merged
Majorfi merged 1 commit into
Majorfi:mainfrom
Nxtmaster10:fix/issue-69
Jul 3, 2026
Merged

fix: decode Immich v3 numeric asset duration (#69)#71
Majorfi merged 1 commit into
Majorfi:mainfrom
Nxtmaster10:fix/issue-69

Conversation

@Nxtmaster10

@Nxtmaster10 Nxtmaster10 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #69.

Immich v3 changed the asset duration field from a string ("0:00:00.000000") to a number of milliseconds (or null), so decoding it into a Go string aborts every fetch:

json: cannot unmarshal number into Go struct field TAsset.assets.items.duration of type string

This hits the default IMAGE-only search too — animated GIFs are IMAGE-type but report a numeric duration on v3.

Change: add a Duration type (underlying string) whose UnmarshalJSON accepts a string (v2), a number (v3), or null; TAsset.Duration uses it and the "duration" extractor returns string(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 duration decodes 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 -race pass. Verified against a live Immich v3.0.0 instance: aborts before, full clean pass after.

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.
@Majorfi

Majorfi commented Jul 2, 2026

Copy link
Copy Markdown
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 Majorfi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Majorfi Majorfi merged commit fbc5c8b into Majorfi:main Jul 3, 2026
1 check failed
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.
@Nxtmaster10 Nxtmaster10 deleted the fix/issue-69 branch July 3, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not working on Latest RC Immich 3.0.0 - Breaking change with duration

2 participants