fix: handle renamed "item" key in playlist tracks#775
Open
maxmaxme wants to merge 1 commit into
Open
Conversation
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.
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.
Spotify's Feb 2026 API migration renamed the playlist track wrapper from
tracktoitemand deprecatedtrack.PlaylistTrackstill expectstrack, soget_playlist/get_playlist_itemsnow blow up on the new payload: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
itemback totrackinPlaylistTrack.__pre_deserialize__, same asPlaylistalready does fortracks→items. Oldtrackpayloads still work, so both shapes are fine during the deprecation window. Also madePlaylistTrackstolerate a missingitemslist (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