Skip to content

fix(connect): fall back to index when context unavailable resolving track - #1747

Open
zeemawn wants to merge 1 commit into
librespot-org:devfrom
zeemawn:fix/spirc-context-unavailable-fallback
Open

fix(connect): fall back to index when context unavailable resolving track#1747
zeemawn wants to merge 1 commit into
librespot-org:devfrom
zeemawn:fix/spirc-context-unavailable-fallback

Conversation

@zeemawn

@zeemawn zeemawn commented Aug 22, 2026

Copy link
Copy Markdown

When resolving the current track by URI or UID, SpircTask calls
get_context(ContextType::Default)?. If the Default context is not
available, the ? propagates the error out of the whole track-resolution
path and the request is abandoned.

On a long-running Connect device this happens regularly, and shows up as:

WARN  librespot_connect::state::context] couldnt load context info because: context is not available. type: Default
WARN  librespot_connect::spirc] failed filling up next_track during stopping: Invalid state { context is not available. type: Default }
ERROR librespot_connect::spirc] failed to handle request: Invalid state { could not find track None in context of 200 }

Since a fallback_index is already available at that point, this handles
the error instead of propagating it: fall back to that index (or 0) and
log a warning, so playback continues rather than the request failing.

Observed on a Raspberry Pi 3B+ running as a persistent Connect endpoint,
where the Default context is frequently unavailable after idle periods.

🤖 Generated with Claude Code

…rack

get_context() returning Err propagated out of the track-resolution path,
aborting the request. Fall back to the provided index (or 0) and warn
instead, so playback continues when the Default context is unavailable.
Copilot AI lite review requested due to automatic review settings August 22, 2026 11:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates Connect track resolution to fall back when the Default context is unavailable.

Changes:

  • Handles missing context during URI and UID resolution.
  • Logs warnings and uses the fallback index or zero.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread connect/src/spirc.rs
Comment on lines +1399 to +1400
warn!("context unavailable when resolving track by UID, using fallback index {fallback_index:?}: {why}");
Ok(fallback_index.unwrap_or_default())
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.

2 participants