Skip to content

Fix album unmarshal error when ALB_CONTRIBUTORS is an empty array - #5

Merged
sayem314 merged 1 commit into
d-fi:mainfrom
tom-burzynski:fix/album-contributors-empty-array
Sep 1, 2026
Merged

Fix album unmarshal error when ALB_CONTRIBUTORS is an empty array#5
sayem314 merged 1 commit into
d-fi:mainfrom
tom-burzynski:fix/album-contributors-empty-array

Conversation

@tom-burzynski

Copy link
Copy Markdown
Contributor

GetAlbumInfo fails on albums without contributor metadata (e.g. various-artists soundtracks):

ERR Failed to unmarshal detailed album info: json: cannot unmarshal array into Go struct field AlbumType.ALB_CONTRIBUTORS of type struct { MainArtist []string "json:\"main_artist\"" }

Reproducible with d-fi -q 320 -u https://www.deezer.com/us/album/6090427.

The cause: album.getData returns ALB_CONTRIBUTORS as an empty JSON array instead of an object when there are no contributors. This PR extracts the anonymous struct into a named AlbumContributors type with an UnmarshalJSON that accepts both forms, mirroring the existing SongContributors handling in types/tracks.go, and adds tests covering the object, [], and {} cases.

Deezer's album.getData returns ALB_CONTRIBUTORS as an empty JSON array
instead of an object for albums without contributor metadata (e.g.
various-artists soundtracks), which made GetAlbumInfo fail with:

  json: cannot unmarshal array into Go struct field
  AlbumType.ALB_CONTRIBUTORS

Extract the anonymous struct into a named AlbumContributors type with
an UnmarshalJSON that accepts both forms, mirroring the existing
SongContributors handling in types/tracks.go.

Reproducible with album 6090427.
@sayem314
sayem314 merged commit 7ee49cb into d-fi:main Sep 1, 2026
1 check passed
@sayem314

sayem314 commented Sep 1, 2026

Copy link
Copy Markdown
Member

Thank you. Will submit new version later today.

@tom-burzynski
tom-burzynski deleted the fix/album-contributors-empty-array branch September 3, 2026 07:06
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.

2 participants