#1427·spotifyd

OpenUri plays the next track because album track number is treated as a zero-based index

Author: DocwatZCreated Sep 1, 2026Updated Sep 1, 2026

Title: OpenUri plays the next track because album track number is treated as a zero-based index

Hi — I hit a reproducible off-by-one in OpenUri on spotifyd 0.4.2.

Summary

When OpenUri is called with a track URI, spotifyd resolves the track to its album context and then passes the track's 1-based album track number directly to PlayingTrack::Index, which appears to be 0-based. The result is that selecting track N starts track N+1.

Reproduction

  1. Start spotifyd 0.4.2 with MPRIS enabled.
  2. Call org.mpris.MediaPlayer2.Player.OpenUri with a track URI.
  3. Observe that the following track starts instead.

Concrete example from my library:

  • Requested: spotify:track:2scagq6TX4bKXQ5tXPXiqR (Goin' Out West - 2023 Remaster)
  • Actual playback: Murder In The Red Barn - 2023 Remaster

I verified the same pattern on several other tracks/albums:

  • Rain Dogs started Midtown
  • Downtown Train and Hold On both played the expected next track when the selection was adjusted to compensate
  • track 1 / track 2 / last-track cases all reproduce the same off-by-one if the plain track URI is used

Expected

OpenUri should start the exact track referenced by the URI.

Actual

It starts the next track on the album.

Source citation

In src/dbus_mpris.rs on v0.4.2, OpenUri does:

rust
SpotifyUri::Track { .. } => {
    let track = Track::get(&session, &uri).await?;
    (track.number as u32, track.album.id.to_uri()?)
}
...
playing_track: Some(librespot_connect::PlayingTrack::Index(playing_track_index))

The log also shows the mismatch directly, e.g.:

loading context_uri spotify:album:4VNqy9FUAFCvwE6XqrtlOn with playing_track_index 10
Loading <Murder In The Red Barn - 2023 Remaster> with Spotify URI <spotify:track:2scagq6TX4bKXQ5tXPXiqR>

For reference, track 10 of that album is Goin' Out West - 2023 Remaster, while index 10 loads track 11.

Notes

I’m on spotifyd 0.4.2-1. This is reproducible even when playback is otherwise working normally.