From 060395885bf5d6b90271b2ceccff6df1069040e8 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Tue, 14 Apr 2026 10:40:42 -0600 Subject: [PATCH] fix(release-watch): backfill album.artist from artists[0] on getNewReleases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AlbumDto from Qobuz carries both legacy singular 'artist' and current 'artists[]' array. /favorite/getNewReleases omits the singular field and only populates the array, so our Album struct (which has a default serde Artist) deserialized an empty name — every Release Watch card on Home read 'Unknown Artist'. Pre-process the JSON response items before deserializing: when 'artist' is absent or null, copy artists[0] into it. Keeps the rest of the album-list plumbing untouched. cc --- crates/qbz-qobuz/src/client.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/crates/qbz-qobuz/src/client.rs b/crates/qbz-qobuz/src/client.rs index cff470aee..e467c7bb9 100644 --- a/crates/qbz-qobuz/src/client.rs +++ b/crates/qbz-qobuz/src/client.rs @@ -825,7 +825,34 @@ impl QobuzClient { // and the caller already knows the offset/limit it asked for, so // we project onto SearchResultsPage to stay compatible with // the rest of the album-list plumbing. - let items_value = response.get("items").cloned().unwrap_or(Value::Null); + // + // Note on shape: AlbumDto carries both `artist` (singular, legacy) + // and `artists` (array, current). `/favorite/getNewReleases` tends + // to omit `artist` and only populate `artists[]`, which made our + // `Album` struct deserialize an empty `artist` and the UI show + // "Unknown Artist". Backfill `artist` from `artists[0]` before + // parsing so the existing deserializer just works. + let mut items_value = response.get("items").cloned().unwrap_or(Value::Null); + if let Some(items_arr) = items_value.as_array_mut() { + for item in items_arr { + if let Some(obj) = item.as_object_mut() { + let needs_backfill = obj + .get("artist") + .map(|v| v.is_null()) + .unwrap_or(true); + if needs_backfill { + if let Some(first_artist) = obj + .get("artists") + .and_then(|a| a.as_array()) + .and_then(|arr| arr.first()) + .cloned() + { + obj.insert("artist".to_string(), first_artist); + } + } + } + } + } let items: Vec = serde_json::from_value(items_value).map_err(|e| { log::warn!( "[API] get_release_watch items parse error: {}. Body (first 600 chars): {}",