Skip to content

Do not read Spotify's answers to player commands as JSON - #24

Merged
chriopter merged 1 commit into
chriopter:mainfrom
sean-imus:fix/spotify-plain-text-reply
Oct 16, 2026
Merged

chriopter merged 1 commit into
chriopter:mainfrom
sean-imus:fix/spotify-plain-text-reply

Conversation

@sean-imus

@sean-imus sean-imus commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator
spotify-error

Playing a song shows "play: Unexpected token 'p', "p2JKrMekJa"... is not valid JSON" in the corner, although the song plays.

Spotify answers some player commands with a plain-text id instead of an empty body, and api() in player.html parsed every non-empty answer as JSON. The play went through, but the error ended send() early, so the repeat and shuffle that follow a play could go unsent.

No caller of api() reads its answer (all are PUT commands), so it no longer reads one. A test plays against a plain-text answer and checks that play, repeat and shuffle all go out.

Checked: node --test …/spotify/web/player.test.mjs (the new test fails without the change), cargo test, and plays on my account in dev/run gui: the error is gone.

🤖 Generated with Claude Code

Spotify answers some player commands with a plain-text id ("p2JKrMekJa…")
instead of an empty body. api() parsed every non-empty answer as JSON,
so a play that went through still failed: the window showed "play:
Unexpected token 'p' … is not valid JSON", and the error ended send()
early, so the repeat and shuffle that follow a play could go unsent.
Every api() call is a command whose answer nobody reads, so it no longer
reads one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chriopter
chriopter merged commit 9530ee7 into chriopter:main Oct 16, 2026
2 checks passed
@sean-imus
sean-imus deleted the fix/spotify-plain-text-reply branch October 16, 2026 22:49
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