mirror of
https://github.com/instructkr/claude-code.git
synced 2026-06-04 11:36:44 +00:00
fix: classify mcp show missing server argument
This commit is contained in:
@@ -297,6 +297,8 @@ fn classify_error_kind(message: &str) -> &'static str {
|
||||
"session_load_failed"
|
||||
} else if message.contains("unsupported ACP invocation") {
|
||||
"unsupported_acp_invocation"
|
||||
} else if message.starts_with("missing_argument:") {
|
||||
"missing_argument"
|
||||
} else if message.contains("unsupported skills action") {
|
||||
"unsupported_skills_action"
|
||||
} else if message.contains("unrecognized argument") || message.contains("unknown option") {
|
||||
@@ -13476,6 +13478,11 @@ mod tests {
|
||||
classify_error_kind("unknown_option: unknown system-prompt option: --foo."),
|
||||
"unknown_option"
|
||||
);
|
||||
// #830: known command with missing required argument must not collapse to unknown.
|
||||
assert_eq!(
|
||||
classify_error_kind("missing_argument: mcp show requires a server name."),
|
||||
"missing_argument"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -2448,6 +2448,38 @@ fn agents_plugins_mcp_unknown_subcommand_have_hint_774() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mcp_show_missing_server_name_returns_missing_argument_830() {
|
||||
let root = unique_temp_dir("mcp-show-missing-830");
|
||||
fs::create_dir_all(&root).expect("temp dir");
|
||||
|
||||
let output = run_claw(&root, &["--output-format", "json", "mcp", "show"], &[]);
|
||||
assert!(
|
||||
!output.status.success(),
|
||||
"mcp show without server must fail"
|
||||
);
|
||||
assert_eq!(output.status.code(), Some(1), "exit code must be 1 (#830)");
|
||||
assert!(
|
||||
output.stderr.is_empty(),
|
||||
"JSON mcp show missing-argument error must keep stderr empty (#830), got: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
let parsed: serde_json::Value = serde_json::from_slice(&output.stdout)
|
||||
.expect("mcp show missing server should emit valid JSON on stdout");
|
||||
assert_eq!(parsed["kind"], "mcp");
|
||||
assert_eq!(parsed["action"], "show");
|
||||
assert_eq!(parsed["status"], "error");
|
||||
assert_eq!(parsed["error_kind"], "missing_argument");
|
||||
assert!(
|
||||
parsed["hint"]
|
||||
.as_str()
|
||||
.unwrap_or_default()
|
||||
.contains("mcp show <server>"),
|
||||
"hint should contain usage example, got: {}",
|
||||
parsed["hint"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn interactive_only_guard_batch_769_to_771() {
|
||||
// #769-#771: a sweep of slash-only verbs with args that previously fell to
|
||||
|
||||
Reference in New Issue
Block a user