Repository navigation
fix(api): report a relinked track under the uri it was requested by - #448
Merged
devgianlu merged 1 commit intoNov 18, 2026
Merged
Conversation
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>
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.
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.
getUnrestrictedTrackcopies the alternative's gid into the track metadata, and the API then reports that gid as the track'suriin:/statusmetadataeventnext_track/player/queuetrack.uriin/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
newApiResponseStatusMediaAsdescribes the media under the uri the caller knows it by:RequestedId, whichStreamalready keeps for this caseOnly 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
TestApiTrackKeepsTheUriOfARelinkedTrackcovers 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.🤖 Generated with Claude Code