From 79d45b96f3dfa1f5bf7d55d48ae01592e6b87e91 Mon Sep 17 00:00:00 2001 From: Thomas Frans Date: Sun, 12 Oct 2025 22:10:07 +0200 Subject: [PATCH] fix: prevent crash when song has no artist (#1720) When loading this playlist (https://open.spotify.com/playlist/2onE4ObADgp1NuBzciYF0Q), ncspot would crash. The exact cause is not clear, but it seems to be caused by the songs not being available and therefore not having a valid artist. Therefore ensure we have a default value for artists in case one isn't available. --- CHANGELOG.md | 1 + src/model/playable.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d88fbe5..9af274f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Playlist retrieval crashing when list contains podcast episodes - Crash when shifting a song by an amount greater than the queue's length +- Crash when displaying songs that do not have an (available) artist ## [1.3.1] diff --git a/src/model/playable.rs b/src/model/playable.rs index 72cf2c3..71bd5fb 100644 --- a/src/model/playable.rs +++ b/src/model/playable.rs @@ -38,7 +38,9 @@ impl Playable { .replace( "%artist", if let Some(artists) = playable.artists() { - artists.first().unwrap().clone().name + artists + .first() + .map_or(String::from(""), |artist| artist.name.clone()) } else { String::new() }