fix: handle renamed "item" key in playlist tracks - #775
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.
|
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions. |
|
The issue is still relevant |
|
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions. |
|
The issue is still relevant |
|
Thanks for picking this up — this is a real production issue. I hit it on Home Assistant 2026.8.x (Spotify integration fails with While testing I found three edge cases the current diff doesn't cover:
My hardened version (normalize Happy to open a follow-up PR with the hardening + tests, or adjust this one — whatever you prefer. Thanks again for the fix. |
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