Skip to content

Tolerate missing thumbnails when parsing playlist items - #974

Merged
sigma67 merged 2 commits into
sigma67:mainfrom
MarvinSchenkel:fix/tolerate-missing-playlist-thumbnails
Aug 8, 2026
Merged

Tolerate missing thumbnails when parsing playlist items#974
sigma67 merged 2 commits into
sigma67:mainfrom
MarvinSchenkel:fix/tolerate-missing-playlist-thumbnails

Conversation

@MarvinSchenkel

Copy link
Copy Markdown
Contributor

parse_playlist reads the thumbnail with nav(data, THUMBNAIL_RENDERER) and no none_if_absent. Some library shelf cards return a thumbnail renderer with an empty thumbnail object. nav then raises:

KeyError: "Unable to find 'thumbnails' using path ['thumbnailRenderer', 'musicThumbnailRenderer', 'thumbnail', 'thumbnails'] on {}, exception: 'thumbnails'"

parse_content_list has no per-item error handling, so one such card makes the whole get_library_playlists() call fail. The user gets no playlists at all.

The title field in the same function already guards against this case. parse_video and parse_related_artist in the same module also read the thumbnail with none_if_absent.

Reported downstream at music-assistant/support#6011.

Changes

  • parse_playlist returns thumbnails: None instead of raising when the thumbnail is absent or empty.
  • Added tests/parsers/test_browsing.py covering the four shapes: no renderer, empty renderer, empty music renderer, and empty thumbnail object.

@MarvinSchenkel
MarvinSchenkel marked this pull request as ready for review August 7, 2026 16:35
Copilot AI lite review requested due to automatic review settings August 7, 2026 16:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes parse_playlist resilient to playlist items whose thumbnail renderer exists but contains an empty/missing thumbnail.thumbnails payload, preventing a single malformed card from causing get_library_playlists() to fail entirely.

Changes:

  • Update parse_playlist to call nav(..., none_if_absent=True) for playlist thumbnails so missing/empty thumbnail structures yield thumbnails: None instead of raising.
  • Add parser tests covering valid thumbnails and four “missing/empty thumbnail” renderer shapes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
ytmusicapi/parsers/browsing.py Makes playlist thumbnail parsing tolerant of absent/empty thumbnail payloads by allowing nav to return None.
tests/parsers/test_browsing.py Adds coverage for valid thumbnails plus multiple missing/empty thumbnail renderer shapes to prevent regressions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings August 8, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.77%. Comparing base (72d47b3) to head (bdde0a6).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #974   +/-   ##
=======================================
  Coverage   95.77%   95.77%           
=======================================
  Files          47       47           
  Lines        2723     2723           
=======================================
  Hits         2608     2608           
  Misses        115      115           
Flag Coverage Δ
unittests 95.77% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@sigma67
sigma67 merged commit aa766e5 into sigma67:main Aug 8, 2026
5 checks passed
sigma67 added a commit that referenced this pull request Aug 10, 2026
#974 guarded parse_playlist only; the same empty-renderer entries break
every other parser that reads thumbnail data unconditionally.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

3 participants