diff --git a/crates/garmin-cli/src/cli/commands/health.rs b/crates/garmin-cli/src/cli/commands/health.rs index f3b373c..b5b465f 100644 --- a/crates/garmin-cli/src/cli/commands/health.rs +++ b/crates/garmin-cli/src/cli/commands/health.rs @@ -957,11 +957,18 @@ pub async fn hrv(date: Option, profile: Option) -> Result<()> { let path = format!("/hrv-service/hrv/{}", date); - let data: serde_json::Value = client.get_json(&oauth2, &path).await?; - println!("HRV Data for {}", date); println!("{}", "-".repeat(40)); + // Garmin returns 204 when HRV is not available for a date (for example, + // before the device has produced an overnight HRV measurement). That is a + // valid no-data response, not a malformed API response. + let Some(data): Option = client.get_optional_json(&oauth2, &path).await? + else { + println!("No HRV data available."); + return Ok(()); + }; + if let Some(summary) = data.get("hrvSummary") { if let Some(weekly) = summary.get("weeklyAvg").and_then(|v| v.as_i64()) { println!("Weekly Avg: {} ms", weekly);