Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions hindsight-cli/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ fn format_error_message(err: &anyhow::Error, api_url: &str) -> String {
);
}

// Preserve validation details before looking for timeout keywords. A fast
// HTTP 400 may legitimately explain that a requested mode would time out;
// classifying that body as a transport timeout hides the server's fix.
if err_str.contains("400 Bad Request") || err_str.contains("(400)") {
return format!(
"{} {}\n\n{}\n {}\n\n{}\n {}",
"✗".bright_red().bold(),
"Request rejected (400)".bright_red().bold(),
"API URL:".bright_yellow(),
api_url.bright_white(),
"Server response:".bright_yellow(),
err_str.bright_white()
);
}

// Timeout
if err_str.contains("timeout") || err_str.contains("Timeout") {
return format!(
Expand Down Expand Up @@ -213,3 +228,21 @@ pub fn print_config_help() {
println!(" 3. Default (http://localhost:8888)");
println!();
}

#[cfg(test)]
mod tests {
use super::format_error_message;

#[test]
fn http_400_body_that_mentions_timeout_is_not_reported_as_a_timeout() {
let error = anyhow::anyhow!(
"API request failed (400 Bad Request): \
{{\"detail\":\"Batch operations will timeout in synchronous mode. Please set async=true.\"}}"
);

let message = format_error_message(&error, "http://localhost:8888");

assert!(message.contains("Batch operations will timeout in synchronous mode"));
assert!(!message.contains("Request timed out"));
}
}
2 changes: 1 addition & 1 deletion skills/hindsight-docs/references/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "0.8.4"
"version": "0.8.5"
},
"paths": {
"/health": {
Expand Down