Skip to content

[BUG] Librespot fails when using DJ X Mode while switching from locally playing to using librespot #143

@cfacer

Description

@cfacer

Describe the bug:
While having the DJ X playlist selected and playing locally in spotify, user is unable select librespot speaker to play from. Resulting logs in docker container show the following error:

librespot_connect::spirc] Invalid state { the provided context has no tracks }

Adding this bug to gioF71/librespot-docker as this is the image being used yet I was unable to find anything in the librespot-org/librespot issues list pertaining to this.

To Reproduce:

  1. Open Spotify on a client device
  2. Select the DJ X playlist and start playing locally
  3. From the "Connect to a device" icon (speaker), select your librespot device
  4. Review logs

Expected behavior:
Formerly librespot used to just discard the DJ X notifications and pickup with the next song being played.

Docker run command:
docker compose up -d

Docker-compose.yaml file:

#version: "3"
services:
    librespot:
        image: giof71/librespot:develop-2025-08-11-bookworm
        container_name: librespot_new
        restart: unless-stopped
        network_mode: host
        environment:
          - BACKEND=pipe
          - DEVICE=/mnt/pipe/librespot
          - DEVICE_NAME=Librespot-HomeAudio
          - PGID=1000
          - PUID=1000
        volumes:
            - /home/user/Code/homeaudio/fifo:/mnt/pipe:rw

Logs

librespot_new  | 2025-08-29T15:39:02.773208555Z Current user id is [0]
librespot_new  | 2025-08-29T15:39:02.773674839Z BACKEND=[pipe]
librespot_new  | 2025-08-29T15:39:02.773876032Z User mode with PUID=[1000] PGID=[1000] AUDIO_GID=[]
librespot_new  | 2025-08-29T15:39:02.773887213Z Ensuring user with uid:[1000] gid:[1000] exists ...
librespot_new  | 2025-08-29T15:39:02.775161995Z Group with gid [1000] does not exist, creating...
librespot_new  | 2025-08-29T15:39:02.801591660Z Group [librespot-group] with gid [1000] created.
librespot_new  | 2025-08-29T15:39:02.802633496Z User with uid [1000] does not exist, creating...
librespot_new  | 2025-08-29T15:39:02.851629997Z User [librespot-user] with uid [1000] created.
librespot_new  | 2025-08-29T15:39:02.851648517Z Home directory [/home/librespot-user] not found, creating.
librespot_new  | 2025-08-29T15:39:02.852762631Z . done.
librespot_new  | 2025-08-29T15:39:02.852773871Z Setting ownership of [/home/librespot-user] to [librespot-user:librespot-group] ...
librespot_new  | 2025-08-29T15:39:02.853674506Z Done.
librespot_new  | 2025-08-29T15:39:02.853711633Z WARNING: AUDIO_GID is mandatory for user mode and alsa backend
librespot_new  | 2025-08-29T15:39:02.853719969Z WARNING: Ignore the previous warning if you set PGID to the audio group
librespot_new  | 2025-08-29T15:39:02.853723104Z Setting ownership of volumes to [librespot-user:librespot-group] ...
librespot_new  | 2025-08-29T15:39:02.855108790Z Done.
librespot_new  | 2025-08-29T15:39:02.855433725Z Discovery is enabled.
librespot_new  | 2025-08-29T15:39:02.855448413Z Using zeroconf backend [libmdns]
librespot_new  | 2025-08-29T15:39:02.855617496Z Additional arguments have not been specified.
librespot_new  | 2025-08-29T15:39:02.860144968Z Command Line: [/usr/bin/librespot --backend pipe --name 'Librespot-HomeAudio' --device /mnt/pipe/librespot --zeroconf-backend libmdns]
librespot_new  | 2025-08-29T15:39:02.860161158Z Running in user mode ...
librespot_new  | 2025-08-29T15:39:02.876213413Z [2025-08-29T15:39:02Z INFO  librespot] librespot 0.6.0-dev ba3d501 (Built on 2025-08-11, Build ID: pUDMLQhT, Profile: release)
librespot_new  | 2025-08-29T15:39:02.878085371Z [2025-08-29T15:39:02Z INFO  librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Log(60.0)
librespot_new  | 2025-08-29T15:39:02.878172761Z [2025-08-29T15:39:02Z INFO  librespot_playback::convert] Converting with ditherer: tpdf
librespot_new  | 2025-08-29T15:39:02.878178705Z [2025-08-29T15:39:02Z INFO  librespot_playback::audio_backend::pipe] Using StdoutSink (pipe) with format: S16
librespot_new  | 2025-08-29T15:39:37.796059566Z [2025-08-29T15:39:37Z WARN  librespot_core::apresolve] Failed to resolve all access points, using fallbacks
librespot_new  | 2025-08-29T15:39:37.796099762Z [2025-08-29T15:39:37Z WARN  librespot_core::apresolve] Resolve access points error: Service unavailable { client error (Connect) }
librespot_new  | 2025-08-29T15:39:37.796105732Z [2025-08-29T15:39:37Z INFO  librespot_core::session] Connecting to AP "ap.spotify.com:443"
librespot_new  | 2025-08-29T15:39:37.975895017Z [2025-08-29T15:39:37Z INFO  librespot_core::session] Authenticated as 'REDACTED_SPOTIFY_USERNAME' !
librespot_new  | 2025-08-29T15:39:37.975967820Z [2025-08-29T15:39:37Z INFO  librespot_core::session] Country: "US"
librespot_new  | 2025-08-29T15:39:38.099861864Z [2025-08-29T15:39:38Z WARN  librespot_core::apresolve] Failed to resolve all access points, using fallbacks
librespot_new  | 2025-08-29T15:39:38.099904068Z [2025-08-29T15:39:38Z WARN  librespot_core::apresolve] Resolve access points error: Service unavailable { client error (Connect) }
librespot_new  | 2025-08-29T15:39:38.213211323Z [2025-08-29T15:39:38Z WARN  librespot_core::apresolve] Failed to resolve all access points, using fallbacks
librespot_new  | 2025-08-29T15:39:38.213233350Z [2025-08-29T15:39:38Z WARN  librespot_core::apresolve] Resolve access points error: Service unavailable { client error (Connect) }
librespot_new  | 2025-08-29T15:39:38.213236208Z [2025-08-29T15:39:38Z INFO  librespot_core::spclient] Resolved "spclient.wg.spotify.com:443" as spclient access point
librespot_new  | 2025-08-29T15:39:38.384246395Z [2025-08-29T15:39:38Z INFO  librespot_connect::spirc] active device is <REDACTED> with session <REDACTED>
librespot_new  | 2025-08-29T15:39:38.504150343Z [2025-08-29T15:39:38Z WARN  librespot_connect::state::context] couldn't load context info because: context is not available. type: Default
librespot_new  | 2025-08-29T15:39:38.584232476Z [2025-08-29T15:39:38Z INFO  librespot_playback::player] Loading <Inner Light> with Spotify URI <spotify:track:40tPP3K10yMZxwnT65REKj>
librespot_new  | 2025-08-29T15:39:38.675892971Z [2025-08-29T15:39:38Z INFO  librespot_connect::spirc] session update: <Ok(NEW_SESSION)> for self, current session_id REDACTED, new session_id REDACTED
librespot_new  | 2025-08-29T15:39:38.762708419Z [2025-08-29T15:39:38Z INFO  librespot_playback::player] <Inner Light> (257984 ms) loaded
librespot_new  | 2025-08-29T15:39:39.243949886Z [2025-08-29T15:39:39Z ERROR librespot_connect::state::context] context didn't have any tracks: Context {
librespot_new  | 2025-08-29T15:39:39.243975728Z         uri: Some(
librespot_new  | 2025-08-29T15:39:39.243979050Z             "spotify:playlist:37i9dQZF1EYkqdzj48dyYq",
librespot_new  | 2025-08-29T15:39:39.243981941Z         ),
librespot_new  | 2025-08-29T15:39:39.243984415Z         url: Some(
librespot_new  | 2025-08-29T15:39:39.243986882Z             "context://spotify:playlist:37i9dQZF1EYkqdzj48dyYq",
librespot_new  | 2025-08-29T15:39:39.243989504Z         ),
librespot_new  | 2025-08-29T15:39:39.243992045Z         metadata: {
librespot_new  | 2025-08-29T15:39:39.243994610Z             "context_owner": "spotify",
librespot_new  | 2025-08-29T15:39:39.243997455Z             "format_list_type": "unknown",
librespot_new  | 2025-08-29T15:39:39.244000208Z             "home.card.dj.transcript_text": "Hey it's your DJ. You know I love being your DJ, right?",
librespot_new  | 2025-08-29T15:39:39.244003058Z             "home.card.tag_color": "#FF0D72EA",
librespot_new  | 2025-08-29T15:39:39.244005630Z             "context_description": "DJ",
librespot_new  | 2025-08-29T15:39:39.244008240Z             "home.card.jellyfish_bottom_color": "#7F1E95D7",
librespot_new  | 2025-08-29T15:39:39.244010914Z             "home.card.jellyfish_animation": "https://lexicon-assets.spotifycdn.com/DJ_Lottie_tighter.json",
librespot_new  | 2025-08-29T15:39:39.244013836Z             "home.card.dj.transcript_id": "offbeat1",
librespot_new  | 2025-08-29T15:39:39.244016489Z             "context_long_description": "DJ",
librespot_new  | 2025-08-29T15:39:39.244019137Z             "home.card.background_color": "#FF0A59B8",
librespot_new  | 2025-08-29T15:39:39.244032907Z             "lexicon_set_type": "your_dj",
librespot_new  | 2025-08-29T15:39:39.244035796Z             "home.card.jellyfish_top_color": "#FF19E68C",
librespot_new  | 2025-08-29T15:39:39.244038465Z             "home.card.jellyfish_mid_color": "#CB1ED7BC",
librespot_new  | 2025-08-29T15:39:39.244041216Z             "lexicon_context_url": "hm://lexicon-session-provider/context-resolve/v2/session?contextUri=spotify:playlist:37i9dQZF1EYkqdzj48dyYq",
librespot_new  | 2025-08-29T15:39:39.244044191Z             "add_context_load_reason": "true",
librespot_new  | 2025-08-29T15:39:39.244046919Z             "home.card.text_color": "#FFFFFFFF",
librespot_new  | 2025-08-29T15:39:39.244049516Z         },
librespot_new  | 2025-08-29T15:39:39.244051959Z         restrictions: MessageField(
librespot_new  | 2025-08-29T15:39:39.244054434Z             None,
librespot_new  | 2025-08-29T15:39:39.244056882Z         ),
librespot_new  | 2025-08-29T15:39:39.244059299Z         pages: [
librespot_new  | 2025-08-29T15:39:39.244061755Z             ContextPage {
librespot_new  | 2025-08-29T15:39:39.244064158Z                 page_url: None,
librespot_new  | 2025-08-29T15:39:39.244066685Z                 next_page_url: None,
librespot_new  | 2025-08-29T15:39:39.244069125Z                 metadata: {},
librespot_new  | 2025-08-29T15:39:39.244071554Z                 tracks: [],
librespot_new  | 2025-08-29T15:39:39.244073978Z                 loading: None,
librespot_new  | 2025-08-29T15:39:39.244076399Z                 special_fields: SpecialFields {
librespot_new  | 2025-08-29T15:39:39.244078866Z                     unknown_fields: UnknownFields {
librespot_new  | 2025-08-29T15:39:39.244081341Z                         fields: None,
librespot_new  | 2025-08-29T15:39:39.244083756Z                     },
librespot_new  | 2025-08-29T15:39:39.244086288Z                     cached_size: CachedSize {
librespot_new  | 2025-08-29T15:39:39.244088765Z                         size: 0,
librespot_new  | 2025-08-29T15:39:39.244091331Z                     },
librespot_new  | 2025-08-29T15:39:39.244093794Z                 },
librespot_new  | 2025-08-29T15:39:39.244096210Z             },
librespot_new  | 2025-08-29T15:39:39.244098625Z         ],
librespot_new  | 2025-08-29T15:39:39.244101001Z         loading: None,
librespot_new  | 2025-08-29T15:39:39.244103461Z         special_fields: SpecialFields {
librespot_new  | 2025-08-29T15:39:39.244106030Z             unknown_fields: UnknownFields {
librespot_new  | 2025-08-29T15:39:39.244108508Z                 fields: None,
librespot_new  | 2025-08-29T15:39:39.244111259Z             },
librespot_new  | 2025-08-29T15:39:39.244114612Z             cached_size: CachedSize {
librespot_new  | 2025-08-29T15:39:39.244117023Z                 size: 0,
librespot_new  | 2025-08-29T15:39:39.244119472Z             },
librespot_new  | 2025-08-29T15:39:39.244121839Z         },
librespot_new  | 2025-08-29T15:39:39.244124191Z     }
librespot_new  | 2025-08-29T15:39:39.244126775Z [2025-08-29T15:39:39Z ERROR librespot_connect::spirc] Invalid state { the provided context has no tracks }
librespot_new  | 2025-08-29T15:39:39.244377151Z [2025-08-29T15:39:39Z WARN  librespot_connect::state::context] couldn't load context info because: context is not available. type: Default
librespot_new  | 2025-08-29T15:39:39.244394892Z [2025-08-29T15:39:39Z ERROR librespot_connect::context_resolver] setup of state failed: Invalid state { context is not available. type: Default }, last used resolve ResolveContext {
librespot_new  | 2025-08-29T15:39:39.244398158Z         resolve: Uri(
librespot_new  | 2025-08-29T15:39:39.244400326Z             "spotify:playlist:37i9dQZF1EYkqdzj48dyYq",
librespot_new  | 2025-08-29T15:39:39.244402612Z         ),
librespot_new  | 2025-08-29T15:39:39.244404609Z         fallback: Some(
librespot_new  | 2025-08-29T15:39:39.244406857Z             "spotify:track:40tPP3K10yMZxwnT65REKj",
librespot_new  | 2025-08-29T15:39:39.244409447Z         ),
librespot_new  | 2025-08-29T15:39:39.244412003Z         update: Default,
librespot_new  | 2025-08-29T15:39:39.244414435Z         action: Replace,
librespot_new  | 2025-08-29T15:39:39.244416787Z     }
librespot_new  | 2025-08-29T15:43:46.066146037Z [2025-08-29T15:43:46Z INFO  librespot_connect::spirc] Not playing next track because there are no more tracks left in queue.
librespot_new  | 2025-08-29T15:43:46.066170074Z [2025-08-29T15:43:46Z WARN  librespot_connect::spirc] failed filling up next_track during stopping: Invalid state { context is not available. type: Default }
librespot_new  | 2025-08-29T15:45:00.265347647Z [2025-08-29T15:45:00Z WARN  librespot_connect::state::context] couldn't load context info because: context is not available. type: Default
librespot_new  | 2025-08-29T15:45:00.265379580Z [2025-08-29T15:45:00Z WARN  librespot_connect::state::context] couldn't load context info because: context is not available. type: Default
librespot_new  | 2025-08-29T15:45:00.401384506Z [2025-08-29T15:45:00Z INFO  librespot_playback::player] Loading <Highway to Hell> with Spotify URI <spotify:track:2zYzyRzz6pRmhPzyfMEC8s>
librespot_new  | 2025-08-29T15:45:00.599525834Z [2025-08-29T15:45:00Z INFO  librespot_playback::player] <Highway to Hell> (208400 ms) loaded

Operating system(please complete the following information):

  • OS: Ubuntu 24.04 LTS
  • Architecture: amd64

Additional context
Attached logs are from a fresh start of the docker container, attempting to push audio to librespot while DJ X playlist is playing a song, then waiting and eventually selecting a song to play directly (Highway to Hell) which works without issue. Timing gap is due to performing testing while documenting bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions