fix(#716): align 5 resume-path error JSON envelopes from legacy type:error shape to standard kind/action/status/error_kind/exit_code contract

This commit is contained in:
YeonGyu-Kim
2026-05-26 05:04:50 +09:00
parent 76c8d4801e
commit 98f8926998
3 changed files with 40 additions and 10 deletions

View File

@@ -3006,9 +3006,12 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
eprintln!(
"{}",
serde_json::json!({
"type": "error",
"error": short_reason,
"kind": kind,
"action": "restore",
"status": "error",
"error_kind": kind,
"error": short_reason,
"exit_code": 1,
"hint": hint,
})
);
@@ -3061,9 +3064,12 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
eprintln!(
"{}",
serde_json::json!({
"type": "error",
"error": format!("/{cmd_root} is not yet implemented in this build"),
"kind": "unsupported_command",
"action": "resume",
"status": "error",
"error_kind": "unsupported_command",
"error": format!("/{cmd_root} is not yet implemented in this build"),
"exit_code": 2,
"command": raw_command,
})
);
@@ -3080,9 +3086,12 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
eprintln!(
"{}",
serde_json::json!({
"type": "error",
"error": format!("unsupported resumed command: {raw_command}"),
"kind": "unsupported_resumed_command",
"action": "resume",
"status": "error",
"error_kind": "unsupported_resumed_command",
"error": format!("unsupported resumed command: {raw_command}"),
"exit_code": 2,
"command": raw_command,
})
);
@@ -3096,8 +3105,12 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
eprintln!(
"{}",
serde_json::json!({
"type": "error",
"kind": "cli_parse",
"action": "resume",
"status": "error",
"error_kind": "cli_parse",
"error": error.to_string(),
"exit_code": 2,
"command": raw_command,
})
);
@@ -3133,8 +3146,12 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
eprintln!(
"{}",
serde_json::json!({
"type": "error",
"kind": "resume_command_error",
"action": "resume",
"status": "error",
"error_kind": "resume_command_error",
"error": error.to_string(),
"exit_code": 2,
"command": raw_command,
})
);
@@ -4434,8 +4451,12 @@ fn enforce_broad_cwd_policy(
eprintln!(
"{}",
serde_json::json!({
"type": "error",
"kind": "broad_cwd",
"action": "abort",
"status": "error",
"error_kind": "broad_cwd",
"error": message,
"exit_code": 1,
})
);
}

View File

@@ -523,7 +523,14 @@ fn resumed_stub_command_emits_not_implemented_json() {
assert!(!output.status.success());
let stderr = String::from_utf8(output.stderr).expect("utf8");
let parsed: Value = serde_json::from_str(stderr.trim()).expect("should be json");
assert_eq!(parsed["type"], "error");
assert_eq!(
parsed["status"], "error",
"stub command should emit status:error"
);
assert_eq!(
parsed["kind"], "unsupported_command",
"stub command should emit kind:unsupported_command"
);
assert!(
parsed["error"]
.as_str()