From 0e548bcf72671e6e6e661e90192bcb7f2f442032 Mon Sep 17 00:00:00 2001 From: akbash Date: Tue, 25 Aug 2026 01:44:10 +0300 Subject: fix: report agent explain file errors as json (#3023) refs #3022 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> --- tests/cli/agents.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/cli') diff --git a/tests/cli/agents.rs b/tests/cli/agents.rs index 3164b802..c3e98f86 100644 --- a/tests/cli/agents.rs +++ b/tests/cli/agents.rs @@ -1,5 +1,34 @@ use super::harness::*; +#[test] +fn agent_explain_missing_file_reports_json_error() { + let base = unique_test_dir(); + let missing = base.join("missing-screen.txt"); + let output = run_named_cli( + &base.join("config"), + &base.join("runtime"), + &[ + "agent", + "explain", + "--file", + missing.to_str().unwrap(), + "--agent", + "claude", + "--json", + ], + ); + + assert_eq!(output.status.code(), Some(1)); + assert!(output.stdout.is_empty()); + let error: serde_json::Value = serde_json::from_slice(&output.stderr).unwrap(); + assert_eq!(error["id"], "cli:agent:explain"); + assert_eq!(error["error"]["code"], "agent_explain_file_read_failed"); + assert!(error["error"]["message"] + .as_str() + .unwrap() + .contains(missing.to_str().unwrap())); +} + fn write_delayed_shell_and_fake_pi( base: &Path, shell_delay_seconds: &str, -- cgit v1.2.3