Repository navigation
Conversation
Capability CLI argument guards threw plain `new Error(<remedy>)`. In --json mode `runCommandWithRuntime` rethrows instead of printing the message through `runtime.error`, and `failure-output.ts` only prints `humanOutput` for `ExpectedCliError`. The remedy therefore disappeared and stderr showed the generic "The CLI command failed. / For help, run `openclaw doctor`." while the JSON envelope still carried the real reason. Route the 11 capability flag guards through `throwExpectedCliError`, the canonical owner already used by the numeric guards in the same commands, so the remedy renders in both output modes. Exit codes, the JSON envelope shape and non-JSON output are unchanged. The `--agent` guard in `tts-runtime.ts` stays a plain `Error` because open PR openclaw#194702 removes that gate. Tests fold into the existing cases instead of adding suites: the `invalidModelRunOptionCases` table gains the `--local --gateway` and blank-`--agent` rows, and the prompt-file/stdin tables drop the two scenario rows whose guard now reports through `ExpectedCliError` — the same remedy is asserted with its class in the option table and in the prompt-source conflict case. Net test lines go down.
|
🦞👀 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 makes eleven capability argument guards display their existing remedies on stderr when JSON output is enabled. Example: Run openclaw capability model run --prompt hi --thinking turbo-mode --json.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR provides a focused, demonstrated fix for a current-main diagnostic bug, with no actionable defects found; CI is still running. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCapability command handlers validate CLI arguments and pass failures through the shared command runtime to the root renderer, which produces stderr diagnostics and JSON failure envelopes. flowchart TD
A[CLI arguments] --> B[Capability argument guards]
B --> C[Expected CLI error]
C --> D[Shared command runtime]
D --> E[Root failure renderer]
E --> F[Actionable stderr]
E --> G[JSON stdout]
Technical reviewBest possible solution: Use the existing expected-error owner at these argument guards while preserving their validation, messages and machine output. Do we have a high-confidence way to reproduce the issue? Current-main source confirms the plain-error path into generic stderr rendering, and the supplied before/after CLI output demonstrates the failure; no target code was executed during this read-only review. Is this the best way to solve the issue? This is the smallest complete repair for the stated guard family: classify existing remedies at their producers instead of broadening shared rendering policy, and retain existing suites without new production machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 56ca2fae9015. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +7, Tests -8. Total -1 across 9 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:
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 13, 2026, 5:28 PM ET / 22:28 UTC (Revision 2). |
|
Proof with the built CLI ( With
Same on both lanes: stdout JSON ( Controls, identical on both lanes:
All 11 message strings are unchanged from main. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in d08fbbc. Thanks @SunnyShu0925. |
…penclaw#198471) fix(cli): show capability argument errors on stderr with --json The argument checks in openclaw capability model, image and tts threw plain errors, so with --json stderr showed only "The CLI command failed." and an openclaw doctor hint, while the check's own fix message appeared only inside the JSON on stdout. The 11 checks now throw the same messages through the existing expected-CLI-error path, so the message reaches stderr. Message text, stdout JSON and exit codes are unchanged, and runtime failures that are not argument checks still take the generic path. No new text. Evidence: the built CLI in a secretless node:24.22.1 container with an empty config and no credentials, five argument checks (an invalid thinking level, --local with --gateway, an invalid image aspect ratio, a tts model without a provider, tts set-persona without a persona), main twice and candidate twice. With --json, main's stderr showed only the generic failure and the Doctor hint; with this change it shows the existing fix message. Stdout JSON and exit code 1 are the same on both, the same checks without --json print the same stderr, a run with no provider auth still takes the generic path, and model list and run --help output is byte-identical. Net -7 test lines. Details: openclaw#198471 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
…198662) fix(cli): show the capability inspect unknown-name error on stderr with --json openclaw capability inspect threw a plain error for an unknown capability name, so with --json stderr showed only "The CLI command failed." and an openclaw doctor hint while "Unknown capability: <name>" appeared only inside the JSON on stdout. It now throws the same message through the existing expected-CLI-error path, as the other capability argument checks do since #198471. Message text, stdout JSON and the exit code are unchanged. No new text. Evidence: the built CLI in a secretless node:24.22.1 container with no network and isolated state, main once and candidate once. With --name bogus --json, main's stderr showed only the generic failure and the Doctor hint; with this change it shows "Unknown capability: bogus" (byte-identical to main's message). Stdout JSON and exit code 1 are the same on both, text mode prints the same error, and a valid capability with --json prints the same metadata. Net -1 test lines. Details: #198662 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
…198861) fix(cli): show openclaw message argument errors on stderr with --json With --json, `openclaw message` argument checks (numeric options such as --limit, --delete-days and poll durations, and --poll-anonymous with --poll-public) threw a plain error, so stderr showed only "The CLI command failed." and the doctor hint while the reason appeared only in the JSON on stdout. They now throw the same messages through the existing expected-CLI-error path, as the capability checks do since #198471 and #198662. Message text, stdout JSON and exit codes are unchanged. No new text. Evidence: source tier with isolated state; the checks run before any channel plugin loads. --limit 0, a bad poll duration, and --poll-anonymous with --poll-public, each with --json: main's stderr had only the generic failure and the doctor hint; this change prints the existing reason. Stdout JSON and exit codes match on both, and text mode and a valid --limit behave the same. Vitest-source: the updated tests fail on base and pass here. Net -1 test lines. The one red check, checks-fast-baseline-ratchets, is inherited from #198857. Receipts: #198861 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#198662) fix(cli): show the capability inspect unknown-name error on stderr with --json openclaw capability inspect threw a plain error for an unknown capability name, so with --json stderr showed only "The CLI command failed." and an openclaw doctor hint while "Unknown capability: <name>" appeared only inside the JSON on stdout. It now throws the same message through the existing expected-CLI-error path, as the other capability argument checks do since openclaw#198471. Message text, stdout JSON and the exit code are unchanged. No new text. Evidence: the built CLI in a secretless node:24.22.1 container with no network and isolated state, main once and candidate once. With --name bogus --json, main's stderr showed only the generic failure and the Doctor hint; with this change it shows "Unknown capability: bogus" (byte-identical to main's message). Stdout JSON and exit code 1 are the same on both, text mode prints the same error, and a valid capability with --json prints the same metadata. Net -1 test lines. Details: openclaw#198662 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#198861) fix(cli): show openclaw message argument errors on stderr with --json With --json, `openclaw message` argument checks (numeric options such as --limit, --delete-days and poll durations, and --poll-anonymous with --poll-public) threw a plain error, so stderr showed only "The CLI command failed." and the doctor hint while the reason appeared only in the JSON on stdout. They now throw the same messages through the existing expected-CLI-error path, as the capability checks do since openclaw#198471 and openclaw#198662. Message text, stdout JSON and exit codes are unchanged. No new text. Evidence: source tier with isolated state; the checks run before any channel plugin loads. --limit 0, a bad poll duration, and --poll-anonymous with --poll-public, each with --json: main's stderr had only the generic failure and the doctor hint; this change prints the existing reason. Stdout JSON and exit codes match on both, and text mode and a valid --limit behave the same. Vitest-source: the updated tests fail on base and pass here. Net -1 test lines. The one red check, checks-fast-baseline-ratchets, is inherited from openclaw#198857. Receipts: openclaw#198861 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
A script or agent that runs a capability CLI command with
--jsonand mistypes a flag gets no actionable output.openclaw capability model run --prompt hi --thinking turbo-mode --jsonprints[openclaw] The CLI command failed.plusFor help, run openclaw doctor.on stderr — the remedy the guard already composed ("Invalid thinking level. Use one of: off|minimal|low|…") never reaches the terminal, even though the JSON envelope on stdout carries it. The same command without--jsonprints the remedy. The failure lane that automation reads is therefore the one lane that hides the advice, and the hint sends the operator to the wrong next step:doctorcannot repair a mistyped flag.src/cli/capability-cli/raise their operator remedy as a plainError.runCommandWithRuntimerethrows plain errors when JSON output is active, and the root renderer prints a message only for expected CLI errors, socapabilityfailures fall back to the generic title plus the Doctor hint.throwExpectedCliError/ExpectedCliErrorowner insrc/cli/expected-cli-error.ts, message text verbatim.shared.ts(3 guards),model.ts(3),tts.ts(3),image.ts(1),tts-runtime.ts(1) — production +18/-11. Regression assertions folded into existing cases in the four capability suites, net -8 test lines, no new test file.--jsonenvelope bytes, and text-mode output. No guard became stricter or looser; only the error envelope changed.Why This Change Was Made
The renderer already distinguishes the two kinds of failure:
formatCliFailureLinesprintshumanOutputverbatim whenisExpectedCliErrorholds, and otherwise prints the generic title plusFor help, run openclaw doctor.unless the command path is in a small show-reason whitelist (update,connect,node run, …).capabilityis not in that whitelist, andrunCommandWithRuntimedeliberately rethrows in JSON mode so the envelope and the stderr block stay owned by the root renderer. A plainErrortherefore loses its advice exactly once: in JSON mode. Converting the guard sites to the owner class makes the capability CLI agree with every other operator-facing CLI remedy, which is the shape merged in #192127, #190366 and #196710 and what the four currently open per-site siblings (#198333, #198329, #191233, #191237) adopt.Alternatives considered and rejected: adding
capabilityto the renderer's show-reason whitelist would print raw reasons for every capability failure including provider and runtime faults, a larger blast radius than one guard family needs. Doing the conversion in the renderer or inrunCommandWithRuntimewould re-derive, at a shared boundary, a contract the error owner already owns. A new error class is unnecessary —throwExpectedCliError(message)setsmessage,humanOutputandmachineOutputto the same string, which is exactly what these single-line remedies need.One guard was deliberately left alone:
src/cli/capability-cli/tts-runtime.ts:242("--agent is only supported with local TTS provider inspection.") stays a plainErrorbecause open PR #194702 deletes that gate; converting a line that is being removed would only manufacture a rebase conflict.User Impact
--jsoncallers ofcapability model run,capability image generate|editandcapability tts …now see the flag remedy on stderr instead of a Doctor pointer, in the same words the text lane already used. Machine consumers are unaffected: the envelope is byte-identical before and after. Successful invocations, exit codes and non-JSON output are untouched.Evidence
Thirteen guards — the eleven converted, the unchanged
tts-runtime.ts:242control, and an already-correct numeric-option control — each run twice (text,--json) on both arms: frozenorigin/mainafa871c6e91and this headdd73d491fc3. Both arms use the shipped source entry (node --import ./scripts/tsx.mjs src/entry.ts …) withHOMEandXDG_RUNTIME_DIRon a scratch directory holding a minimal config, so no real state is touched; inputs reach the guards before any network or provider work, so no mocks are involved. All 52 runs exit 1.--json)origin/mainafa871c6e91)dd73d491fc3)capability model run --prompt ' '--prompt cannot be empty or whitespace-only.capability model run --prompt hi --thinking turbo-modeInvalid thinking level. Use one of: off…ultra.capability model run --prompt hi --prompt-stdinUse exactly one of --prompt, --prompt-file, or --prompt-stdin.capability model run --prompt hi --local --gatewayPass only one of --local or --gateway.capability model run --prompt hi --model not-a-provider/Model overrides must use the form <provider/model>.capability model run --prompt hi --agent ' '--agent must not be blankcapability image generate --prompt p --aspect-ratio 16x9--aspect-ratio must be a W:H ratio of positive numbers, like 16:9capability tts convert --text hi --model gpt-4o-mini-ttsTTS model overrides must use the form <provider/model>.capability tts convert --text hi --provider xiaomi --model openai/gpt-4o-mini-ttsTTS --provider must match the provider in --model.capability tts set-persona --local--persona is required unless --off is setcapability tts set-provider --local --provider ''--provider is required--json)cmpbyte-identical to beforecapability tts providers --gateway --agent main(guard left plain)After, guard 2 verbatim:
Before, same command (stdout line unchanged, stderr line replaced):
Contract preserved, measured rather than asserted:
cmpover all 13 guards shows the--jsonstdout byte-identical between arms (the envelope already carried the message, so scripts that parse it keep working) and the text-mode stderr byte-identical between arms (the lane that already worked is untouched). Only JSON-mode stderr changes, and only from generic to remedy. Thetts-runtime.ts:242control stays generic on both arms, which is the carve-out above, not a missed site.Unit lane, same tests with the five production files reverted to
origin/mainand restored by recorded blob — a mutation test on the fix itself:Consumers were run, not reasoned about. Every suite that imports the changed modules — the four edited files plus
capability-cli.help,capability-cli.lazy,capability-cli/shared,capability-cli/model.state-owner,model.auth-status,model.resources,local-account-secrets,command-secret-resolution.coverage,program/register.subclis,capability-cli/local-runners.account-secretsand the rootfailure-outputrenderer suite: 14 files, 259 tests, green on this head.src/cli/capability-cli/shared.test.tsneeded no change and stays exactly as onorigin/main; the--local/--gatewayand blank---agentguards it already exercises are also covered through the shipped CLI in the table above, so no second unit copy of them was added.Gates:
git diff --checkclean; the repository formatter reports "All matched files use the correct format" on all 9 touched files; noconfig/test-lines-allocations/entry is needed because the test delta is -8; no test-only export was added and no new test file created.Open PR collision check (submission-day sweep, 2026-11-14). Changed-file comparison over the recent open-PR snapshot plus keyword lanes (
throwExpectedCliError,capability-cli,aspect-ratio,thinking level,prompt-stdin) found four same-family per-site PRs with zero file overlap (#198333models-cli.ts, #198329nodes-cli, #191233security-cli, #191237worktrees-cli), and two open PRs that touch my files without touching my semantics: maintainer PR #198294 (credential owner) overlaps only themodel.tsimport block —git merge-treeagainst its head conflicts on that one import line and nothing else — and #195363 (symlink image inputs, open since 11-08, currentlyDIRTY) re-indents themodel runblock that contains guards 1-3, a whitespace-only rebase conflict. Neither converts any capability guard, so this change is not superseded; both resolve mechanically on the next rebase. Gate 2.5: the fourteen commits touchingsrc/cli/capability-cli/in the last 14 days (#198214, #198141, #196816, #195206, …) route state ownership and failure-output formatting, none asserts that a flag guard must stay a plainError, and #196816 in fact narrows the generic-line path. The defect is still live: re-run againstorigin/main68542b21d0d, six commits past the arm above,capability model run --prompt hi --thinking turbo-mode --jsonagain exits 1 with only the generic title and the Doctor hint on stderr, andgit merge-treeof this head against that tip reports no conflict.What was not tested locally: the repository lint wrapper refuses this worktree's symlinked install ("Declaration input escapes checkout"), and direct
oxlintcannot load itssolid-lintJS plugin here, so lint is left to CI on this head. A targetedtscover the nine touched files produced no diagnostic in any of them; the six errors it printed are pre-existing module-resolution noise from the sharednode_modulessymlink (libphonenumber-js,qrcodetypes,JSON.rawJSON) in files this change does not touch.openclaw capability … --jsonwas not run against a live Gateway, which these guards never reach: all thirteen inputs fail in argument validation before any transport call.