Skip to content

fix(api): report a relinked track under the uri it was requested by - #448

Merged
devgianlu merged 1 commit into
devgianlu:masterfrom
isnogudus:fix/report-requested-track-uri
Nov 18, 2026
Merged

devgianlu merged 1 commit into
devgianlu:masterfrom
isnogudus:fix/report-requested-track-uri

Conversation

@isnogudus

Copy link
Copy Markdown
Contributor

When Spotify relinks a track to an alternative, the API reports the alternative's id as the track's uri. The context, the queue and the user's library still name the track by its original uri, so clients can no longer find the playing track.

Problem

Spotify relinks a track that is not available in the user's country to an alternative: the same recording under another id. getUnrestrictedTrack copies the alternative's gid into the track metadata, and the API then reports that gid as the track's uri in:

  • /status
  • the metadata event
  • next_track
  • /player/queue
  • track.uri in /context/tracks. Here the same entry carries two uris, for example:
{"uri": "spotify:track:27OLQa9tqXGQ8ock5mmnlL", "track": {"uri": "spotify:track:77FKI1difRbue2Qwrhj4Er", "name": "Chocolate", …}}

The context, the queue and the user's library all name the track by the original uri. A client that looks for the playing track in the list it shows cannot find it. Library checks, such as whether the track is liked, ask about the wrong id.

Fix

newApiResponseStatusMediaAs describes the media under the uri the caller knows it by:

  • the stream's RequestedId, which Stream already keeps for this case
  • the queue entry's uri
  • the context list's uri

Only what the API reports changes; playback still uses the alternative. When no requested uri is known, the media's own uri is used as before.

Testing

  • TestApiTrackKeepsTheUriOfARelinkedTrack covers the status, the context track list, and the cases without a requested uri. It fails without the fix.
  • go test -race -tags "test_unit test_integration" ./... passes.
  • Live: a relinked track from Liked Songs now reports the uri the collection holds.

🤖 Generated with Claude Code

Spotify relinks a track that is not available in the user's country to an
alternative with the same recording but another id, and the player then
carries the alternative's gid in the media. The API reported that gid as
the track's uri in /status, the metadata event, next_track, the queue and
the context track list, while the context, the queue and the user's
library name the track by the original uri. A client looking for the
playing track in the list it shows could not find it, and checks against
the library, such as whether the track is liked, asked about the wrong id.

Describe the media under the uri the caller knows it by: the stream's
requested id, the queue entry's uri or the context list's uri.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devgianlu
devgianlu merged commit 3cff09d into devgianlu:master Nov 18, 2026
11 checks 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