From 1483c05913e89643fcc62da3b32c310e797dfe7a Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sat, 31 Jan 2026 15:58:36 -0600 Subject: [PATCH] Fix: Validate stream URL response before making HEAD request - Add validation to check if URL is empty before returning StreamUrl - Add debug logging for JSON response keys - Return proper error instead of silently using empty URL - This prevents 'builder error' from HEAD request to empty URL --- src-tauri/src/api/client.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/api/client.rs b/src-tauri/src/api/client.rs index a48c6977e..101716b01 100644 --- a/src-tauri/src/api/client.rs +++ b/src-tauri/src/api/client.rs @@ -582,6 +582,7 @@ impl QobuzClient { match response.status() { StatusCode::OK => { let json: Value = response.json().await?; + log::debug!("Stream URL response JSON keys: {:?}", json.as_object().map(|o| o.keys().collect::>())); // Check for restrictions let restrictions: Vec = json @@ -589,8 +590,15 @@ impl QobuzClient { .and_then(|v| serde_json::from_value(v.clone()).ok()) .unwrap_or_default(); + // Validate that we got an actual URL + let url = json["url"].as_str().unwrap_or("").to_string(); + if url.is_empty() { + log::error!("Stream URL response missing 'url' field. Response: {:?}", json); + return Err(ApiError::ApiResponse("Stream URL response missing 'url' field".to_string())); + } + Ok(StreamUrl { - url: json["url"].as_str().unwrap_or("").to_string(), + url, format_id: json["format_id"].as_u64().unwrap_or(0) as u32, mime_type: json["mime_type"].as_str().unwrap_or("").to_string(), sampling_rate: json["sampling_rate"].as_f64().unwrap_or(0.0),