Skip to content

fix: handle renamed "item" key in playlist tracks#775

Open
maxmaxme wants to merge 1 commit into
joostlek:mainfrom
maxmaxme:fix/playlist-item-track-rename
Open

fix: handle renamed "item" key in playlist tracks#775
maxmaxme wants to merge 1 commit into
joostlek:mainfrom
maxmaxme:fix/playlist-item-track-rename

Conversation

@maxmaxme
Copy link
Copy Markdown

Spotify's Feb 2026 API migration renamed the playlist track wrapper from track to item and deprecated track. PlaylistTrack still expects track, so get_playlist/get_playlist_items now blow up on the new payload:

MissingField: Field "track" of type Item is missing in PlaylistTrack instance

This takes down the HA Spotify integration on the new payload — both when the coordinator polls a playing playlist and when browsing playlists in the media browser (home-assistant/core#165877).

Map item back to track in PlaylistTrack.__pre_deserialize__, same as Playlist already does for tracksitems. Old track payloads still work, so both shapes are fine during the deprecation window. Also made PlaylistTracks tolerate a missing items list (non-owned playlists return metadata only — same thing #767 was after).

Added fixtures for the new item-only shape and parametrized them into the existing playlist tests.

Fixes #774

Spotify's February 2026 Web API migration renamed the per-entry track
wrapper from "track" to "item" (tracks.track -> items.item) and marked
"track" deprecated. PlaylistTrack still required "track", so get_playlist
and get_playlist_items raised MissingField/InvalidFieldValue on the new
shape, which breaks the Home Assistant Spotify integration on playlist
playback.

Normalize the new "item" key back to "track" in PlaylistTrack's
__pre_deserialize__ hook -- same pattern already used by
Playlist.__pre_deserialize__ (tracks -> items) and
Album.__pre_deserialize__ (flattening tracks.items). The legacy "track"
key still passes through unchanged, so both shapes work during the
deprecation window. Also tolerate a missing "items" list, since
non-owned playlists now return only metadata.

Tests: new playlist_4.json and playlist_items_2.json fixtures in the
"item"-only shape, parametrized into the existing playlist tests.
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.

get_playlist fails on the new "item" wrapper (Feb 2026 API change)

1 participant