Skip to content

Skip playlist entries whose track is unavailable - #854

Merged
joostlek merged 2 commits into
joostlek:mainfrom
TheeCoderAhmed:fix/skip-unavailable-playlist-tracks
Nov 4, 2026
Merged

joostlek merged 2 commits into
joostlek:mainfrom
TheeCoderAhmed:fix/skip-unavailable-playlist-tracks

Conversation

@TheeCoderAhmed

Copy link
Copy Markdown
Contributor

Proposed Changes

Spotify returns "track": null for playlist entries that are no longer available. PlaylistTrack.track isn't optional, so one such entry makes the whole playlist fail to parse:

mashumaro.exceptions.InvalidFieldValue: Field "track" of type Item in PlaylistTrack has invalid value None

That's what home-assistant/core#181111 runs into when browsing a playlist.

This drops those entries before deserializing, the same way PlaylistTracks already drops local tracks:

  • PlaylistTracks.__pre_deserialize__ (used by get_playlist) now also skips entries without a track.
  • PlaylistTrackResponse (used by get_playlist_items) gets the same filter in a new __pre_deserialize__.

The check is item.get("track", item.get("item")) is not None, so it also works for entries that only carry the newer item key (the rename #775 handles).

Added test_get_playlist_skips_unavailable_tracks and test_get_playlist_items_skips_unavailable_tracks. Each serves an existing fixture with an extra entry whose track and item are null, and checks that only the real entry comes back. Both fail with the error above without the change. The full suite passes (108 tests, snapshots unchanged).

Related Issues

Spotify returns "track": null for playlist entries that are no longer available, which made get_playlist and get_playlist_items fail with InvalidFieldValue for the whole playlist. Drop those entries, like local tracks already are.
@joostlek joostlek added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Nov 4, 2026
Combine the unavailable-track filter with the local-file filter from main.
Check the "item" field before "track", the same order PlaylistTrack uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joostlek
joostlek merged commit 2880ccf into joostlek:main Nov 4, 2026
12 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants