Skip to content

Accept object-shaped profile avatars in profile attributes - #113

Merged
Aran404 merged 2 commits into
Aran404:mainfrom
lordydord:fix/profile-avatar
Nov 24, 2026
Merged

Aran404 merged 2 commits into
Aran404:mainfrom
lordydord:fix/profile-avatar

Conversation

@lordydord

Copy link
Copy Markdown

Summary

Profile.from_dict now accepts the object-shaped avatar that Spotify's profileAttributes query returns:

"avatar": {"sources": [{"url": "...", "width": 64, "height": 64}, {"url": "...", "width": 300, "height": 300}]}

The object is reduced to the URL of its largest source, so Profile.avatar keeps its str | None type. An object with no usable source becomes None, and a plain string is passed through unchanged.

Why

For accounts with a profile picture, get_profile_attributes() currently raises:

BaseClientError: Spotify returned invalid profile attributes: Profile.avatar: value does not match str | None

PlaylistHandler._get_username() goes through this query, so every rootlist mutation fails for those accounts, including create_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 cover the changed behavior: three new cases in tests/test_review_regressions.py (object form picks the largest source; empty or invalid objects become None; a string avatar is unchanged).
  • python -m pytest -q -m "not live": 727 passed, 24 skipped
  • python -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 .
  • Changelog entry under "Unreleased".
  • No credentials, cookies, access tokens, or private account data are included.

🤖 Generated with Claude Code

Graham Lord and others added 2 commits November 24, 2026 09:32
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>

Aran404 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks for tracking this down, reproducing it on a live account, and adding regression tests!

@Aran404
Aran404 merged commit 252dcbc into Aran404:main Nov 24, 2026
1 check passed
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.

2 participants