Skip to content

Conversation

@photovoltex
Copy link
Member

Pretty much just forwards the index given by skip_to so that a track is always played, even when the given uri and the album uri don't match. This seems to be a rare case for some albums.

Fixes #1591

Copilot AI review requested due to automatic review settings September 24, 2025 20:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where tracks wouldn't play when the given URI and album URI don't match by implementing a fallback mechanism. The fix ensures that either the provided index or the first track (index 0) is used as a fallback when track resolution fails.

  • Adds fallback index extraction from skip_to options
  • Modifies track index resolution to use Result type and handle failures gracefully
  • Updates function signatures to pass the fallback index through the call chain

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
connect/src/spirc.rs Implements fallback index logic and error handling for track resolution
discovery/src/lib.rs Removes unnecessary string reference for DNS_SD_SERVICE_NAME parameter
CHANGELOG.md Documents the bug fix in the changelog

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@drobotk
Copy link

drobotk commented Sep 26, 2025

I've been testing this and there seems to still be some bug; I don't have a good repro but sometimes when hopping between albums/singles librespot plays the wrong thing, from not even the correct context. Logs show the new warning added by this PR but with the fallback index being 0. I'm going to try to get a repeatable scenario to share here.

@drobotk
Copy link

drobotk commented Sep 26, 2025

This is the command that causes the wrong thing to play

[2025-09-26T15:18:10Z TRACE librespot_core::dealer::protocol] websocket request: Object {
        "command": Object {
            "context": Object {
                "metadata": Object {
                    "context_description": String("Twenty One Pilots"),
                    "disable-autoplay": String("true"),
                },
                "pages": Array [
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:1El3k8dU3sKyoGUeuyrolH"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/1El3k8dU3sKyoGUeuyrolH/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:2ua0DTF9uqI0AugOvNrumo"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/2ua0DTF9uqI0AugOvNrumo/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:2VHIo87YnEergnRfHnQN3J"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/2VHIo87YnEergnRfHnQN3J/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:5qkGe4UpUa8dsokzuroQ72"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/5qkGe4UpUa8dsokzuroQ72/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:4aE8ZrEif8MgWvFNIbz8I6"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/4aE8ZrEif8MgWvFNIbz8I6/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:1KFWgQTw3EMTQebaaepVBI"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/1KFWgQTw3EMTQebaaepVBI/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:7K7eWZNR5t9UBlrN2ltzLI"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/7K7eWZNR5t9UBlrN2ltzLI/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:5ZSqGFLuXUJUlIObSkN0Bz"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/5ZSqGFLuXUJUlIObSkN0Bz/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:2kAer61g2HN6upL2zXAjzd"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/2kAer61g2HN6upL2zXAjzd/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:1B61NzknoGqafMfKLY7QtZ"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/1B61NzknoGqafMfKLY7QtZ/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:12ElyiIcWOKdZXOgPxJwPN"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/12ElyiIcWOKdZXOgPxJwPN/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:3lXhr0xJlvW6UUuUAM9hb2"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/3lXhr0xJlvW6UUuUAM9hb2/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:0Q5XBpCYFgUWiG9DUWyAmJ"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/0Q5XBpCYFgUWiG9DUWyAmJ/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:5bh5kgZddiyd5ObXOP9Exu"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/5bh5kgZddiyd5ObXOP9Exu/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:4gH0qokNrxFcg6iHF7mNd6"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/4gH0qokNrxFcg6iHF7mNd6/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:4h3HXlnt6lryGzGbWmcFuY"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/4h3HXlnt6lryGzGbWmcFuY/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:29GQfbZF68zQAbyzKX8kq3"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/29GQfbZF68zQAbyzKX8kq3/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:36yNEpiZYBDNUAuhh7QhoQ"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/36yNEpiZYBDNUAuhh7QhoQ/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:517BVw2CemFLW5p0wKLffT"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/517BVw2CemFLW5p0wKLffT/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:0aQZjurM8n5Fw7G55zDUyp"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/0aQZjurM8n5Fw7G55zDUyp/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:5gPTivcCK6JfPNZqoAzP2O"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/5gPTivcCK6JfPNZqoAzP2O/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:621cXqrTSSJi1WqDMSLmbL"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/621cXqrTSSJi1WqDMSLmbL/km"),
                    },
                ],
                "restrictions": Object {},
                "uri": String("spotify:artist:3YQKmKGau1PzlVlkL1iodx"),
            },
            "endpoint": String("play"),
            "logging_params": Object {
                "command_id": String("957186b5b40e799cd0cf1104ec5c5147"),
                "command_initiated_time": Number(1758899891796),
                "command_received_time": Number(1758899891797),
                "device_identifier": String("c726a5fdc8296668ff3a52e6787bfea08bd12b92"),
                "interaction_ids": Array [
                    String("857121dc-472f-475e-bfad-17e29da3d57b"),
                ],
                "page_instance_ids": Array [
                    String("9371756d-5806-41b5-8161-bdd4c01e6ba7"),
                ],
            },
            "options": Object {
                "always_play_something": Bool(false),
                "audio_stream": String("default"),
                "initially_paused": Bool(false),
                "license": String("premium"),
                "player_options_override": Object {},
                "prefetch_level": String("none"),
                "session_id": String(""),
                "skip_to": Object {
                    "page_index": Number(4),
                    "track_index": Number(0),
                    "track_uid": String("a1b13f4a73443b4f7105"),
                    "track_uri": String("spotify:track:3qrTll9OQ9wcejTxPFY0qg"),
                },
                "suppressions": Object {},
                "system_initiated": Bool(false),
            },
            "play_options": Object {
                "only_for_local_device": Bool(false),
                "operation": String("replace"),
                "override_restrictions": Bool(false),
                "reason": String("interactive"),
                "system_initiated": Bool(false),
                "trigger": String("immediately"),
            },
            "play_origin": Object {
                "device_identifier": String("c726a5fdc8296668ff3a52e6787bfea08bd12b92"),
                "feature_identifier": String("artist"),
                "feature_version": String("xpui-snapshot_2025-09-08_1757321627224_8c88c31"),
                "referrer_identifier": String("your_library"),
            },
        },
        "message_id": Number(110783470),
        "play_on_secondary_stream": Null,
        "sent_by_device_id": String("c726a5fdc8296668ff3a52e6787bfea08bd12b92"),
        "target_alias_id": Null,
    }

@drobotk
Copy link

drobotk commented Sep 26, 2025

I have a repro: while connected to librespot: have something playing, then go to an artist page, go to All Releases or similar, scroll down a bit and play something from there. It plays something from something else on the same page.

@photovoltex
Copy link
Member Author

You seem to have found a case where the page_index is provided, I never encountered that before. I have a guess how to handle it tho thanks to your provided command snippet.

@photovoltex
Copy link
Member Author

Could you give this a try @drobotk? I couldn't tested it this time, but it should probably also account for the edge case now. If not we might have to do a bit more then I would hope for.

@drobotk
Copy link

drobotk commented Oct 11, 2025

Same command as above still doesn't play the right thing, but what it plays is different than before. I try to play this but this plays instead.

[2025-10-11T16:05:27Z TRACE librespot_core::dealer::protocol] websocket request: Object {
        "command": Object {
            "context": Object {
                "metadata": Object {
                    "context_description": String("Twenty One Pilots"),
                    "disable-autoplay": String("true"),
                },
                "pages": Array [
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:1El3k8dU3sKyoGUeuyrolH"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/1El3k8dU3sKyoGUeuyrolH/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:2ua0DTF9uqI0AugOvNrumo"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/2ua0DTF9uqI0AugOvNrumo/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:2VHIo87YnEergnRfHnQN3J"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/2VHIo87YnEergnRfHnQN3J/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:5qkGe4UpUa8dsokzuroQ72"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/5qkGe4UpUa8dsokzuroQ72/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:4aE8ZrEif8MgWvFNIbz8I6"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/4aE8ZrEif8MgWvFNIbz8I6/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:1KFWgQTw3EMTQebaaepVBI"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/1KFWgQTw3EMTQebaaepVBI/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:7K7eWZNR5t9UBlrN2ltzLI"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/7K7eWZNR5t9UBlrN2ltzLI/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:5ZSqGFLuXUJUlIObSkN0Bz"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/5ZSqGFLuXUJUlIObSkN0Bz/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:2kAer61g2HN6upL2zXAjzd"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/2kAer61g2HN6upL2zXAjzd/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:1B61NzknoGqafMfKLY7QtZ"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/1B61NzknoGqafMfKLY7QtZ/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:12ElyiIcWOKdZXOgPxJwPN"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/12ElyiIcWOKdZXOgPxJwPN/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:3lXhr0xJlvW6UUuUAM9hb2"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/3lXhr0xJlvW6UUuUAM9hb2/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:0Q5XBpCYFgUWiG9DUWyAmJ"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/0Q5XBpCYFgUWiG9DUWyAmJ/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:5bh5kgZddiyd5ObXOP9Exu"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/5bh5kgZddiyd5ObXOP9Exu/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:4gH0qokNrxFcg6iHF7mNd6"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/4gH0qokNrxFcg6iHF7mNd6/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:4h3HXlnt6lryGzGbWmcFuY"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/4h3HXlnt6lryGzGbWmcFuY/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:29GQfbZF68zQAbyzKX8kq3"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/29GQfbZF68zQAbyzKX8kq3/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:36yNEpiZYBDNUAuhh7QhoQ"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/36yNEpiZYBDNUAuhh7QhoQ/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:517BVw2CemFLW5p0wKLffT"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/517BVw2CemFLW5p0wKLffT/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:0aQZjurM8n5Fw7G55zDUyp"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/0aQZjurM8n5Fw7G55zDUyp/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:5gPTivcCK6JfPNZqoAzP2O"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/5gPTivcCK6JfPNZqoAzP2O/km"),
                    },
                    Object {
                        "metadata": Object {
                            "page_uri": String("spotify:album:621cXqrTSSJi1WqDMSLmbL"),
                        },
                        "page_url": String("hm://artistplaycontext/v1/page/spotify/album/621cXqrTSSJi1WqDMSLmbL/km"),
                    },
                ],
                "restrictions": Object {},
                "uri": String("spotify:artist:3YQKmKGau1PzlVlkL1iodx"),
            },
            "endpoint": String("play"),
            "logging_params": Object {
                "command_id": String("fe3d63932e5342fa16c755b26288f248"),
                "command_initiated_time": Number(1760198727243),
                "command_received_time": Number(1760198727244),
                "device_identifier": String("c726a5fdc8296668ff3a52e6787bfea08bd12b92"),
                "interaction_ids": Array [
                    String("147d938f-edc1-4d34-88d5-5eb2573c061e"),
                ],
                "page_instance_ids": Array [
                    String("074c6760-7efa-4027-9286-691ddc25c05e"),
                ],
            },
            "options": Object {
                "always_play_something": Bool(false),
                "audio_stream": String("default"),
                "initially_paused": Bool(false),
                "license": String("premium"),
                "player_options_override": Object {},
                "prefetch_level": String("none"),
                "session_id": String(""),
                "skip_to": Object {
                    "page_index": Number(4),
                    "track_index": Number(0),
                    "track_uid": String("a1b13f4a73443b4f7105"),
                    "track_uri": String("spotify:track:3qrTll9OQ9wcejTxPFY0qg"),
                },
                "suppressions": Object {},
                "system_initiated": Bool(false),
            },
            "play_options": Object {
                "only_for_local_device": Bool(false),
                "operation": String("replace"),
                "override_restrictions": Bool(false),
                "reason": String("interactive"),
                "system_initiated": Bool(false),
                "trigger": String("immediately"),
            },
            "play_origin": Object {
                "device_identifier": String("c726a5fdc8296668ff3a52e6787bfea08bd12b92"),
                "feature_identifier": String("artist"),
                "feature_version": String("xpui-snapshot_2025-10-06_1759755116809_3be53af"),
                "referrer_identifier": String("your_library"),
            },
        },
        "message_id": Number(1409620373),
        "play_on_secondary_stream": Null,
        "sent_by_device_id": String("c726a5fdc8296668ff3a52e6787bfea08bd12b92"),
        "target_alias_id": Null,
    }
[2025-10-11T16:05:27Z DEBUG librespot_connect::spirc] handling: 'endpoint: play' from c726a5fdc8296668ff3a52e6787bfea08bd12b92
[2025-10-11T16:05:27Z WARN  librespot_connect::state::context] couldn't load context info because: context is not available. type: Default
[2025-10-11T16:05:27Z WARN  librespot_connect::state::context] couldn't load context info because: context is not available. type: Default
[2025-10-11T16:05:27Z DEBUG librespot_connect::spirc] resolving context for load command
[2025-10-11T16:05:27Z TRACE librespot_connect::context_resolver] added spotify:artist:3YQKmKGau1PzlVlkL1iodx to resolver queue
[2025-10-11T16:05:27Z DEBUG librespot_core::http_client] Requesting https://gew4-spclient.spotify.com:443/context-resolve/v1/spotify:artist:3YQKmKGau1PzlVlkL1iodx
[2025-10-11T16:05:27Z DEBUG librespot_connect::spirc] handling next context Some("spotify:artist:3YQKmKGau1PzlVlkL1iodx")
[2025-10-11T16:05:27Z DEBUG librespot_connect::state::context] updated context Default to <Some("spotify:artist:3YQKmKGau1PzlVlkL1iodx")> (10 tracks)
[2025-10-11T16:05:27Z DEBUG librespot_connect::context_resolver] last item of type <Default>, finishing state setup
[2025-10-11T16:05:27Z DEBUG librespot_connect::state] reset_playback with active ctx <Default> fill_up ctx <Default>
[2025-10-11T16:05:27Z DEBUG librespot_connect::state::tracks] set track to: spotify:track:3CRDbSIZ4r5MsZ0YwxuEkn at 0 of 18 tracks
[2025-10-11T16:05:27Z DEBUG librespot_connect::state::tracks] finished filling up next_tracks (17)
[2025-10-11T16:05:27Z DEBUG librespot_connect::spirc] play track <Some(Uri("spotify:track:3qrTll9OQ9wcejTxPFY0qg"))>
[2025-10-11T16:05:27Z WARN  librespot_connect::spirc] Failed to resolve index by Some(Uri("spotify:track:3qrTll9OQ9wcejTxPFY0qg")), using fallback index: Some(4) (Error: could not find track None in context of 18)
[2025-10-11T16:05:27Z DEBUG librespot_connect::spirc] loading with shuffle: <false>, repeat track: <false> context: <false>
[2025-10-11T16:05:27Z DEBUG librespot_connect::state::tracks] set track to: spotify:track:20BFo9REyGdCxrlPmD3xph at 4 of 18 tracks
[2025-10-11T16:05:27Z DEBUG librespot_connect::state] reset_playback with active ctx <Default> fill_up ctx <Default>
[2025-10-11T16:05:27Z DEBUG librespot_connect::state::tracks] set track to: spotify:track:20BFo9REyGdCxrlPmD3xph at 4 of 18 tracks
[2025-10-11T16:05:27Z DEBUG librespot_connect::state] has 4 prev tracks
[2025-10-11T16:05:27Z DEBUG librespot_connect::state::tracks] finished filling up next_tracks (13)
[2025-10-11T16:05:27Z DEBUG librespot_connect::state] updated connect play status playing: true, paused: false, buffering: true
[2025-10-11T16:05:27Z DEBUG librespot_playback::player] command=Load(SpotifyUri("spotify:track:20BFo9REyGdCxrlPmD3xph"), true, 0)
[2025-10-11T16:05:27Z DEBUG librespot_core::dealer::manager] replying to ws request: Success
[2025-10-11T16:05:27Z TRACE librespot_connect::spirc] ==> LoadingPlay
[2025-10-11T16:05:27Z DEBUG librespot_core::http_client] Requesting https://spclient.wg.spotify.com/metadata/4/track/420922292c6f4b9b8e9dcd4aa4dfa97b?product=0&country=PL&salt=1009208400

There also appears to be a regression. With this latest commit, trying to play songs from the album I linked in the Issue it now always plays the first track, index 0.

[2025-10-11T16:11:59Z TRACE librespot_core::dealer::protocol] websocket request: Object {
        "command": Object {
            "context": Object {
                "restrictions": Object {},
                "uri": String("spotify:album:7vYR7oLh93zb38m880M8bd"),
                "url": String("context://spotify:album:7vYR7oLh93zb38m880M8bd"),
            },
            "endpoint": String("play"),
            "logging_params": Object {
                "command_id": String("7f41510e28e6befdb38c760edbaa1d8d"),
                "command_initiated_time": Number(1760199119215),
                "command_received_time": Number(1760199119216),
                "device_identifier": String("c726a5fdc8296668ff3a52e6787bfea08bd12b92"),
                "interaction_ids": Array [
                    String("db219117-7639-4f07-aee4-ef537229afed"),
                ],
                "page_instance_ids": Array [
                    String("55689d57-44fa-42f6-a5fc-f397149d7eb7"),
                ],
            },
            "options": Object {
                "always_play_something": Bool(false),
                "audio_stream": String("default"),
                "initially_paused": Bool(false),
                "license": String("premium"),
                "player_options_override": Object {},
                "prefetch_level": String("none"),
                "session_id": String(""),
                "skip_to": Object {
                    "track_index": Number(9),
                    "track_uid": String("622a188ce71d9ccc0f1d"),
                    "track_uri": String("spotify:track:5SDOB8Zdt8XNt0b0GzgPpg"),
                },
                "suppressions": Object {},
                "system_initiated": Bool(false),
            },
            "play_options": Object {
                "only_for_local_device": Bool(false),
                "operation": String("replace"),
                "override_restrictions": Bool(false),
                "reason": String("interactive"),
                "system_initiated": Bool(false),
                "trigger": String("immediately"),
            },
            "play_origin": Object {
                "device_identifier": String("c726a5fdc8296668ff3a52e6787bfea08bd12b92"),
                "feature_identifier": String("album"),
                "feature_version": String("xpui-snapshot_2025-10-06_1759755116809_3be53af"),
                "referrer_identifier": String("your_library"),
            },
        },
        "message_id": Number(1410012375),
        "play_on_secondary_stream": Null,
        "sent_by_device_id": String("c726a5fdc8296668ff3a52e6787bfea08bd12b92"),
        "target_alias_id": Null,
    }
[2025-10-11T16:11:59Z DEBUG librespot_connect::spirc] handling: 'endpoint: play' from c726a5fdc8296668ff3a52e6787bfea08bd12b92
[2025-10-11T16:11:59Z WARN  librespot_connect::state::context] couldn't load context info because: context is not available. type: Default
[2025-10-11T16:11:59Z WARN  librespot_connect::state::context] couldn't load context info because: context is not available. type: Default
[2025-10-11T16:11:59Z DEBUG librespot_connect::spirc] resolving context for load command
[2025-10-11T16:11:59Z TRACE librespot_connect::context_resolver] added spotify:album:7vYR7oLh93zb38m880M8bd to resolver queue
[2025-10-11T16:11:59Z DEBUG librespot_core::http_client] Requesting https://gew4-spclient.spotify.com:443/context-resolve/v1/spotify:album:7vYR7oLh93zb38m880M8bd
[2025-10-11T16:11:59Z DEBUG librespot_connect::spirc] handling next context Some("spotify:album:7vYR7oLh93zb38m880M8bd")
[2025-10-11T16:11:59Z DEBUG librespot_connect::state::context] updated context Default to <Some("spotify:album:7vYR7oLh93zb38m880M8bd")> (21 tracks)
[2025-10-11T16:11:59Z DEBUG librespot_connect::context_resolver] last item of type <Default>, finishing state setup
[2025-10-11T16:11:59Z DEBUG librespot_connect::state] reset_playback with active ctx <Default> fill_up ctx <Default>
[2025-10-11T16:11:59Z DEBUG librespot_connect::state::tracks] set track to: spotify:track:369UJeRvrV88tPihhNIWlF at 0 of 21 tracks
[2025-10-11T16:11:59Z DEBUG librespot_connect::state::tracks] finished filling up next_tracks (20)
[2025-10-11T16:11:59Z DEBUG librespot_connect::spirc] play track <Some(Uri("spotify:track:5SDOB8Zdt8XNt0b0GzgPpg"))>
[2025-10-11T16:11:59Z WARN  librespot_connect::spirc] Failed to resolve index by Some(Uri("spotify:track:5SDOB8Zdt8XNt0b0GzgPpg")), using fallback index: Some(0) (Error: could not find track None in context of 21)
[2025-10-11T16:11:59Z DEBUG librespot_connect::spirc] loading with shuffle: <false>, repeat track: <false> context: <false>
[2025-10-11T16:11:59Z DEBUG librespot_connect::state::tracks] set track to: spotify:track:369UJeRvrV88tPihhNIWlF at 0 of 21 tracks
[2025-10-11T16:11:59Z DEBUG librespot_connect::state] reset_playback with active ctx <Default> fill_up ctx <Default>
[2025-10-11T16:11:59Z DEBUG librespot_connect::state::tracks] set track to: spotify:track:369UJeRvrV88tPihhNIWlF at 0 of 21 tracks
[2025-10-11T16:11:59Z DEBUG librespot_connect::state::tracks] finished filling up next_tracks (20)
[2025-10-11T16:11:59Z DEBUG librespot_connect::state] updated connect play status playing: true, paused: false, buffering: true
[2025-10-11T16:11:59Z DEBUG librespot_playback::player] command=Load(SpotifyUri("spotify:track:369UJeRvrV88tPihhNIWlF"), true, 0)
[2025-10-11T16:11:59Z DEBUG librespot_core::dealer::manager] replying to ws request: Success
[2025-10-11T16:11:59Z TRACE librespot_connect::spirc] ==> LoadingPlay
[2025-10-11T16:11:59Z DEBUG librespot_core::http_client] Requesting https://spclient.wg.spotify.com/metadata/4/track/65d5c354b0a149fa88393ca38fd2eff7?product=0&country=PL&salt=3528621681

@photovoltex
Copy link
Member Author

Thanks for the testing, I see where my issue for the fix is. I will look into the regression, might be a minor oversight hopefully.

@photovoltex
Copy link
Member Author

So the second issue isn't an easy fix as simply providing a fallback index... It probably makes more sense to limit this PR for now to the initial problem and offload the second issue into a separate topic.

A wrong behavior is more acceptable currently then something that prevents playback entirely.

@photovoltex photovoltex force-pushed the fix/use-index-as-fallback branch from 3681bb3 to f0d6afe Compare October 12, 2025 18:17
@photovoltex
Copy link
Member Author

@drobotk Could you create a new issue for the second issue you encountered here? It's worth fixing but would take some more time.

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.

Can't play certain tracks

2 participants