Reordering is incorrect when duplicate URIs exist #15

Open
opened 2026-08-22 20:31:08 +00:00 by faceguy · 0 comments
Owner

ReorderPlaylistTracks() stores only one current index per URI. Each duplicate occurrence overwrites the preceding occurrence in indexMap.

For some duplicate orders, the lookup returns an index before the current destination position. The local shifting loop at /internal/spotify/playlist.go#L203 handles only targetIndex > i, so it can overwrite entries in its local representation and issue subsequent reorder requests with incorrect positions.

Using original order [A, B, A, C, A] and desired order [A, A, A, B, C] against a Spotify-shaped test server, the function returned success but corrupted its local order to [A, A, A, A, C].

`ReorderPlaylistTracks()` stores only one current index per URI. Each duplicate occurrence overwrites the preceding occurrence in `indexMap`. For some duplicate orders, the lookup returns an index before the current destination position. The local shifting loop at `/internal/spotify/playlist.go#L203` handles only `targetIndex > i`, so it can overwrite entries in its local representation and issue subsequent reorder requests with incorrect positions. Using original order `[A, B, A, C, A]` and desired order `[A, A, A, B, C]` against a Spotify-shaped test server, the function returned success but corrupted its local order to `[A, A, A, A, C]`.
faceguy self-assigned this 2026-08-22 20:31:08 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
faceguy/my-spotify-playlist-sorter-go#15
No description provided.