From 4d10caebc6c41d29e217a21e85849e27a03c1f6a Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Thu, 9 Apr 2026 15:03:36 +0900 Subject: [PATCH] fix(cli): validate --reasoning-effort accepts only low|medium|high Previously any string was accepted and silently forwarded to the API, which would fail at the provider with an unhelpful error. Now invalid values produce a clear error at parse time: invalid value for --reasoning-effort: 'xyz'; must be low, medium, or high 156 CLI tests pass, fmt clean. --- rust/crates/rusty-claude-cli/src/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index e75ee86..052b565 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -476,11 +476,22 @@ fn parse_args(args: &[String]) -> Result { let value = args .get(index + 1) .ok_or_else(|| "missing value for --reasoning-effort".to_string())?; + if !matches!(value.as_str(), "low" | "medium" | "high") { + return Err(format!( + "invalid value for --reasoning-effort: '{value}'; must be low, medium, or high" + )); + } reasoning_effort = Some(value.clone()); index += 2; } flag if flag.starts_with("--reasoning-effort=") => { - reasoning_effort = Some(flag[19..].to_string()); + let value = &flag[19..]; + if !matches!(value, "low" | "medium" | "high") { + return Err(format!( + "invalid value for --reasoning-effort: '{value}'; must be low, medium, or high" + )); + } + reasoning_effort = Some(value.to_string()); index += 1; } "-p" => {