From a84c5761837bcf155e043fdb684fce44bcbb80b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20M=C3=A4nnlein?= Date: Sat, 22 Aug 2026 13:20:46 +0200 Subject: [PATCH] fix(connect): fall back to index when context unavailable resolving track 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. --- connect/src/spirc.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/connect/src/spirc.rs b/connect/src/spirc.rs index fec6057c4..100ebec52 100644 --- a/connect/src/spirc.rs +++ b/connect/src/spirc.rs @@ -1384,12 +1384,22 @@ impl SpircTask { Some(ref playing_track) => Some(match playing_track { PlayingTrack::Index(i) => Ok(*i as usize), PlayingTrack::Uri(uri) => { - let ctx = self.connect_state.get_context(ContextType::Default)?; - ConnectState::find_index_in_context(ctx, |t| &t.uri == uri) + match self.connect_state.get_context(ContextType::Default) { + Ok(ctx) => ConnectState::find_index_in_context(ctx, |t| &t.uri == uri), + Err(why) => { + warn!("context unavailable when resolving track by URI, using fallback index {fallback_index:?}: {why}"); + Ok(fallback_index.unwrap_or_default()) + } + } } PlayingTrack::Uid(uid) => { - let ctx = self.connect_state.get_context(ContextType::Default)?; - ConnectState::find_index_in_context(ctx, |t| &t.uid == uid) + match self.connect_state.get_context(ContextType::Default) { + Ok(ctx) => ConnectState::find_index_in_context(ctx, |t| &t.uid == uid), + Err(why) => { + warn!("context unavailable when resolving track by UID, using fallback index {fallback_index:?}: {why}"); + Ok(fallback_index.unwrap_or_default()) + } + } } }), }