mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-28 08:26:45 +00:00
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:
@@ -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,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user