Repository navigation
Accept object-shaped profile avatars in profile attributes - #113
Merged
Merged
Conversation
Spotify's profileAttributes query now returns avatar as
{"sources": [{"url", "width", "height"}]} instead of a URL string,
which made Profile.from_dict raise and broke every playlist mutation
(create_playlist resolves the username through this query).
Reduce the object form to its largest source URL so avatar stays a str.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thanks for tracking this down, reproducing it on a live account, and adding regression 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.
Summary
Profile.from_dictnow accepts the object-shapedavatarthat Spotify'sprofileAttributesquery returns:The object is reduced to the URL of its largest source, so
Profile.avatarkeeps itsstr | Nonetype. An object with no usable source becomesNone, and a plain string is passed through unchanged.Why
For accounts with a profile picture,
get_profile_attributes()currently raises:PlaylistHandler._get_username()goes through this query, so every rootlist mutation fails for those accounts, includingcreate_playlist. Accounts without an avatar are unaffected, which is probably why tests haven't caught it. I reproduced it on a live account with v2.1.3; with this change, creating, adding to, reordering, editing and deleting a playlist all work.Verification
tests/test_review_regressions.py(object form picks the largest source; empty or invalid objects becomeNone; a string avatar is unchanged).python -m pytest -q -m "not live": 727 passed, 24 skippedpython -m pyright: no new diagnostics. The changed files are clean; the full-repo count is identical with and without this change (the remainder is from optional extras not installed locally).python -m ruff check .python -m black --check .🤖 Generated with Claude Code