From ef31328aab27c83c95bde977aeb771eabf3b3cf3 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Tue, 26 May 2026 23:04:04 +0900 Subject: [PATCH] fix(#759): validate_model_syntax error strings now use newline separator so hint is non-null --- ROADMAP.md | 2 ++ rust/crates/rusty-claude-cli/src/main.rs | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index fd5f01bb..6f559712 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -7683,3 +7683,5 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed) 757. **`--permission-mode bogus` and `--allowedTools` (no value) returned `error_kind:"unknown"` + `hint:null`** — dogfooded 2026-05-26 on `4df14618`. `parse_permission_mode_arg()` error format had no prefix and no `\n`; `--allowedTools` missing-value string was plain. Fix: prefix `parse_permission_mode_arg` error with `invalid_flag_value:` + `\n` valid-values hint (both call sites); prefix `--allowedTools` missing-value with `missing_flag_value:` + `\n` usage hint. Both now classified by existing `missing_flag_value`/`invalid_flag_value` arms added in #756. Source: Jobdori dogfood on `4df14618`, 2026-05-26. 758. **Three remaining `missing value for --X` strings in `parse_init_args` were still untyped** — dogfooded 2026-05-26 on `02d77ae1`. `--cwd`, `--date`, `--session` missing-value errors in the init-args parser used the old plain-string form with no `missing_flag_value:` prefix and no `\n` hint, unlike the main `parse_args` flags fixed in #756/#757. Fix: applied `missing_flag_value:` prefix + `\n` usage hint to all three. `grep '"missing value for --'` now returns zero results outside of test assertions. Source: Jobdori dogfood sweep on `02d77ae1`, 2026-05-26. + +759. **`--model badmodel --output-format json` returned `error_kind:"invalid_model_syntax"` but `hint: null`** — dogfooded 2026-05-26 on `b8b3af6f`. `validate_model_syntax()` had hint text embedded after a period in the error string (no `\n`), so `split_error_hint()` could not extract it. Affected paths: (a) generic invalid format `"invalid model syntax: '{}'. Expected ..."` — joined with `.` not `\n`; (b) spaces-in-model `"contains spaces. Use ..."` — same issue; (c) empty model string — no hint at all. Fix: added `\n` before hint text in all three format strings in `validate_model_syntax`. Source: Jobdori dogfood sweep on `b8b3af6f`, 2026-05-26. diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index 9e871b15..f17191ad 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -1778,12 +1778,12 @@ fn resolve_model_alias_with_config(model: &str) -> String { fn validate_model_syntax(model: &str) -> Result<(), String> { let trimmed = model.trim(); if trimmed.is_empty() { - return Err("model string cannot be empty".to_string()); + return Err("invalid model syntax: model string cannot be empty.\nUsage: --model e.g. --model anthropic/claude-opus-4-7".to_string()); } // Check for spaces (malformed) if trimmed.contains(' ') { return Err(format!( - "invalid model syntax: '{}' contains spaces. Use provider/model format or known alias", + "invalid model syntax: '{}' contains spaces.\nUse provider/model format (e.g., anthropic/claude-opus-4-7) or a known alias.", trimmed )); } @@ -1792,7 +1792,7 @@ fn validate_model_syntax(model: &str) -> Result<(), String> { if parts.len() != 2 || parts[0].is_empty() || parts[1].is_empty() { // #154: hint if the model looks like it belongs to a different provider let mut err_msg = format!( - "invalid model syntax: '{}'. Expected provider/model (e.g., anthropic/claude-opus-4-6)", + "invalid model syntax: '{}'.\nExpected provider/model (e.g., anthropic/claude-opus-4-7)", trimmed ); if trimmed.starts_with("gpt-") || trimmed.starts_with("gpt_") {