Repository navigation
fix(models): surface the --json/--plain conflict as an ExpectedCliError - #196382
Conversation
models list/status reject --json with --plain through a bare Error, which the CLI failure handler swallows into "The CLI command failed." for the route-first commands. Throwing an ExpectedCliError lets the human output carry the option-conflict reason, matching the sibling --probe/--plain check and the invalid-provider check in the same file.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR displays the existing explanation when model commands receive both --json and --plain. Example: Run openclaw models list --json --plain.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current CLI diagnostic bug with a focused change and convincing built-CLI proof; no actionable defects were found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherModel CLI commands pass output flags to a shared validator, and the root CLI failure handler renders its rejection as human-readable stderr and optional JSON. flowchart TD
A[CLI output flags] --> B[Model list or status]
B --> C[Shared flag validator]
C --> D[ExpectedCliError]
D --> E[CLI failure renderer]
E --> F[Conflict message and exit 1]
Technical reviewBest possible solution: Use the existing expected-error contract in the shared validator while preserving the rejection message, JSON envelope, and exit code. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the bare-error path, and supplied built-CLI output demonstrates the failure for both commands; this review ran no target code. Is this the best way to solve the issue? This is the smallest complete repair: change the error classification at the existing shared owner and extend its existing command-boundary regression. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 48beb4002e65. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests 0. Total +1 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 9, 2026, 9:46 PM ET / November 10, 2026, 02:46 UTC (Revision 2). |
… invalid-options case
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Proof on built CLIs (
main, stderr, exit 1 (both commands): this PR, stderr, exit 1 (both commands): The JSON error on stdout ( Controls: stdout, stderr and exit code were identical on main and this PR (after normalizing temp paths, profile name and pids) for:
Tests: I removed the allocation file and folded the check into the existing invalid-options table in |
|
Landed in 1ebc46e. Thanks @wangmiao0668000666. models now shows the real --json/--plain conflict message. |
…or (#196382) fix(models): surface the --json/--plain conflict as an ExpectedCliError openclaw models list --json --plain and models status --json --plain threw a plain Error, so the CLI showed only the generic "The CLI command failed." line instead of the existing message "Choose either --json or --plain, not both." The shared option check now uses ExpectedCliError, as #196094 and #196081 did for related checks. The exit code and the JSON error on stdout are unchanged, and no text is new. Evidence: built CLIs on node 24.22.1 in secretless Docker with an isolated HOME. Both commands with --json --plain printed only the generic failure line on main (exit 1) and the existing conflict message with this change (exit 1); the JSON error on stdout is byte-identical. list --json, list --plain, status --json, status --plain and status --probe --plain are identical on both. Details: openclaw/openclaw#196382 (comment). Thanks @wangmiao0668000666. Co-authored-by: Ayaan Zaidi <[email protected]>
…or (openclaw#196382) fix(models): surface the --json/--plain conflict as an ExpectedCliError openclaw models list --json --plain and models status --json --plain threw a plain Error, so the CLI showed only the generic "The CLI command failed." line instead of the existing message "Choose either --json or --plain, not both." The shared option check now uses ExpectedCliError, as openclaw#196094 and openclaw#196081 did for related checks. The exit code and the JSON error on stdout are unchanged, and no text is new. Evidence: built CLIs on node 24.22.1 in secretless Docker with an isolated HOME. Both commands with --json --plain printed only the generic failure line on main (exit 1) and the existing conflict message with this change (exit 1); the JSON error on stdout is byte-identical. list --json, list --plain, status --json, status --plain and status --probe --plain are identical on both. Details: openclaw#196382 (comment). Thanks @wangmiao0668000666. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes:
openclaw models list --json --plain(andmodels status --json --plain) prints onlyThe CLI command failed. For help, run openclaw doctor.instead of the option-conflict reason. The real message (Choose either --json or --plain, not both.) was hidden from human output.User Impact
User impact: the option-conflict reason is now printed instead of the generic failure line, with the same exit code 1.
--jsonmachine output and the exit code are unchanged; no new wording.Why This Change Was Made
ensureFlagCompatibilityrejects--jsoncombined with--plainby throwing a bareError, which the CLI failure handler classifies as unexpected and replaces with the generic line in human output for the route-firstmodels list/models statuscommands. Throwing anExpectedCliErrorinstead lets the human output carry the option-conflict reason, matching the sibling--probe/--plaincheck (inlist.status-command.ts) and theinvalid providercheck (inlist.list-command.ts) in the same command family.Evidence
Discriminating regression (
src/commands/models/list.prepared-catalog.test.ts): the newrejects --json with --plain as an ExpectedCliErrorcase asserts the rejection is anExpectedCliErrorwith the option message.new Error(...)): test fails — rejection is a plainError, not anExpectedCliError.Real CLI proof through the supported shipped launcher (
node openclaw.mjs, built dist, Node 24, isolated HOME), same build with only the throw changed:Before (base):
After (head):
--jsonmachine output is unchanged ({ "ok": false, "error": { "type": "cli_error", "message": "Choose either --json or --plain, not both." } }).Test-line budget: 7 added lines, allocated in
config/test-lines-allocations/models-json-plain-conflict.txt.Maintainer options
Scope and alternatives
Narrow change to one shared option-compatibility helper plus its regression; JSON schema and exit codes unchanged.
Alternatives considered:
ExpectedCliErrorcontract already exists for exactly this and is what sibling model commands use.