Skip to content

fix(cli): surface capability flag-guard remedies in --json failures - #198471

Merged
obviyus merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/capability-cli-flag-guards-expected-316
Nov 13, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/capability-cli-flag-guards-expected-316

Conversation

@SunnyShu0925

Copy link
Copy Markdown
Contributor

What Problem This Solves

A script or agent that runs a capability CLI command with --json and mistypes a flag gets no actionable output. openclaw capability model run --prompt hi --thinking turbo-mode --json prints [openclaw] The CLI command failed. plus For 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 --json prints 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: doctor cannot repair a mistyped flag.

  • Problem: eleven argument guards in src/cli/capability-cli/ raise their operator remedy as a plain Error. runCommandWithRuntime rethrows plain errors when JSON output is active, and the root renderer prints a message only for expected CLI errors, so capability failures fall back to the generic title plus the Doctor hint.
  • Solution: raise those eleven sites through the canonical throwExpectedCliError / ExpectedCliError owner in src/cli/expected-cli-error.ts, message text verbatim.
  • What changed: 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.
  • What did NOT change: every message string, the exit code (1), the --json envelope 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: formatCliFailureLines prints humanOutput verbatim when isExpectedCliError holds, and otherwise prints the generic title plus For help, run openclaw doctor. unless the command path is in a small show-reason whitelist (update, connect, node run, …). capability is not in that whitelist, and runCommandWithRuntime deliberately rethrows in JSON mode so the envelope and the stderr block stay owned by the root renderer. A plain Error therefore 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 capability to 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 in runCommandWithRuntime would re-derive, at a shared boundary, a contract the error owner already owns. A new error class is unnecessary — throwExpectedCliError(message) sets message, humanOutput and machineOutput to 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 plain Error because open PR #194702 deletes that gate; converting a line that is being removed would only manufacture a rebase conflict.

User Impact

--json callers of capability model run, capability image generate|edit and capability 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:242 control, and an already-correct numeric-option control — each run twice (text, --json) on both arms: frozen origin/main afa871c6e91 and this head dd73d491fc3. Both arms use the shipped source entry (node --import ./scripts/tsx.mjs src/entry.ts …) with HOME and XDG_RUNTIME_DIR on 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.

Guard (with --json) Before (origin/main afa871c6e91) After (this head dd73d491fc3)
1 capability model run --prompt ' ' generic title + Doctor hint --prompt cannot be empty or whitespace-only.
2 capability model run --prompt hi --thinking turbo-mode generic title + Doctor hint Invalid thinking level. Use one of: off…ultra.
3 capability model run --prompt hi --prompt-stdin generic title + Doctor hint Use exactly one of --prompt, --prompt-file, or --prompt-stdin.
4 capability model run --prompt hi --local --gateway generic title + Doctor hint Pass only one of --local or --gateway.
5 capability model run --prompt hi --model not-a-provider/ generic title + Doctor hint Model overrides must use the form <provider/model>.
6 capability model run --prompt hi --agent ' ' generic title + Doctor hint --agent must not be blank
7 capability image generate --prompt p --aspect-ratio 16x9 generic title + Doctor hint --aspect-ratio must be a W:H ratio of positive numbers, like 16:9
8 capability tts convert --text hi --model gpt-4o-mini-tts generic title + Doctor hint TTS model overrides must use the form <provider/model>.
9 capability tts convert --text hi --provider xiaomi --model openai/gpt-4o-mini-tts generic title + Doctor hint TTS --provider must match the provider in --model.
10 capability tts set-persona --local generic title + Doctor hint --persona is required unless --off is set
11 capability tts set-provider --local --provider '' generic title + Doctor hint --provider is required
control: text lane, same 11 inputs (no --json) remedy printed remedy printed, cmp byte-identical to before
control: capability tts providers --gateway --agent main (guard left plain) generic title + Doctor hint generic title + Doctor hint, byte-identical

After, guard 2 verbatim:

$ node --import ./scripts/tsx.mjs src/entry.ts capability model run --prompt hi --thinking turbo-mode --json
stderr: Invalid thinking level. Use one of: off|minimal|low|medium|high|xhigh|adaptive|max|ultra.
stdout: { "ok": false, "error": { "type": "cli_error",
        "message": "Invalid thinking level. Use one of: off|minimal|low|medium|high|xhigh|adaptive|max|ultra." } }
(exit 1)

Before, same command (stdout line unchanged, stderr line replaced):

$ node --import ./scripts/tsx.mjs src/entry.ts capability model run --prompt hi --thinking turbo-mode --json
stderr: [openclaw] The CLI command failed.
        [openclaw] For help, run `openclaw doctor`.
stdout: identical JSON envelope as above
(exit 1)

Contract preserved, measured rather than asserted: cmp over all 13 guards shows the --json stdout 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. The tts-runtime.ts:242 control 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/main and restored by recorded blob — a mutation test on the fix itself:

FAIL src/cli/capability-cli.test.ts > capability cli > rejects invalid model run options [ '--thinking', 'turbo-mode' ] before dispatch
AssertionError: expected Error: exit 1 to be an instance of ExpectedCliError

FAIL src/cli/capability-cli.image-options.test.ts > rejects malformed image generate --aspect-ratio 16x9 before dispatch
AssertionError: expected Error: exit 1 to be an instance of ExpectedCliError

 Test Files  3 failed | 1 passed (4)   Tests  16 failed | 165 passed (181)   # production reverted
 Test Files  4 passed (4)             Tests  181 passed (181)                # this head

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-secrets and the root failure-output renderer suite: 14 files, 259 tests, green on this head. src/cli/capability-cli/shared.test.ts needed no change and stays exactly as on origin/main; the --local/--gateway and blank---agent guards 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 --check clean; the repository formatter reports "All matched files use the correct format" on all 9 touched files; no config/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 (#198333 models-cli.ts, #198329 nodes-cli, #191233 security-cli, #191237 worktrees-cli), and two open PRs that touch my files without touching my semantics: maintainer PR #198294 (credential owner) overlaps only the model.ts import block — git merge-tree against its head conflicts on that one import line and nothing else — and #195363 (symlink image inputs, open since 11-08, currently DIRTY) re-indents the model run block 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 touching src/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 plain Error, and #196816 in fact narrows the generic-line path. The defect is still live: re-run against origin/main 68542b21d0d, six commits past the arm above, capability model run --prompt hi --thinking turbo-mode --json again exits 1 with only the generic title and the Doctor hint on stderr, and git merge-tree of 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 oxlint cannot load its solid-lint JS plugin here, so lint is left to CI on this head. A targeted tsc over the nine touched files produced no diagnostic in any of them; the six errors it printed are pre-existing module-resolution noise from the shared node_modules symlink (libphonenumber-js, qrcode types, JSON.rawJSON) in files this change does not touch. openclaw capability … --json was not run against a live Gateway, which these guards never reach: all thirteen inputs fail in argument validation before any transport call.

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.
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Nov 13, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 13, 2026
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Stderr shows a generic command failure and a Doctor hint.
  • After: Stderr lists the valid thinking levels; stdout JSON and exit code 1 remain unchanged.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A small, useful repair using the canonical error contract, supported by shipped-CLI before/after proof and regression results; final CI remains pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The body records all eleven changed guards through the CLI entry point, with unchanged stdout and text-mode controls; obviyus additionally supplies repeated built-launcher before/after results for representative model, image and TTS failures in a secretless container.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users receiving JSON failures see a generic stderr message directing them to Doctor instead of the existing remedy for an invalid argument.
Reason: The change restores actionable diagnostics through an established owner without changing accepted inputs, options or runtime behavior.

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
Reviewed head: dd73d491fc37015a4a21f536b3ab56120df2b973

Before merge

None.

Findings

None.

Agent review details

How this fits together

Capability 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]
Loading

Technical review

Best 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

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 8d4c9e0 adds src/cli/capability-cli/model.ts:442 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8d4c9e082ec9; files: src/cli/capability-cli/model.ts)
  • Ayaan Zaidi: Raw commit 81daea9 adds src/cli/capability-cli/model.ts:498 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 81daea994d80; files: src/cli/capability-cli/model.ts)
  • Jerome: Raw commit bc097bf adds src/cli/expected-cli-error.ts:27 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: bc097bf6404f; files: src/cli/expected-cli-error.ts)

PR surface

Source +7, Tests -8. Total -1 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 18 11 +7
Tests 4 19 27 -8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 37 38 -1

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Invalid capability flags hide actionable stderr guidance in JSON mode, while machine-readable errors remain available and successful inference is unaffected.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-13T21:56:35.018Z sha dd73d49 :: needs maintainer review before merge. :: none

Reviewed November 13, 2026, 5:28 PM ET / 22:28 UTC (Revision 2).

@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Proof with the built CLI (pnpm build, node openclaw.mjs) in a clean node:24.22.1 container, no network, empty config, no credentials. Each lane ran twice; both rounds matched.

With --json, stderr:

command main afa871c this PR dd73d49
capability model run --prompt hi --thinking turbo-mode The CLI command failed. + Doctor hint Invalid thinking level. Use one of: off|minimal|low|medium|high|xhigh|adaptive|max|ultra.
capability model run --prompt hi --local --gateway same generic lines Pass only one of --local or --gateway.
capability image generate --prompt cat --aspect-ratio wide same generic lines --aspect-ratio must be a W:H ratio of positive numbers, like 16:9
capability tts convert --text hi --model elevenlabs same generic lines TTS model overrides must use the form <provider/model>.
capability tts set-persona same generic lines --persona is required unless --off is set

Same on both lanes: stdout JSON ({"ok":false,"error":{"type":"cli_error","message":...}}, same message) and exit code 1.

Controls, identical on both lanes:

  • The same five commands without --json print the same message on stderr, exit 1.
  • capability model run --prompt hi --local (no provider auth, not an argument check) still prints the generic failure and Doctor hint with --json.
  • capability model list --json and capability model run --help output byte-identical.

All 11 message strings are unchanged from main.

@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 13, 2026
@obviyus
obviyus merged commit d08fbbc into openclaw:main Nov 13, 2026
141 of 142 checks passed
@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Landed in d08fbbc. Thanks @SunnyShu0925.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 14, 2026
…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]>
obviyus added a commit that referenced this pull request Nov 14, 2026
…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]>
obviyus added a commit that referenced this pull request Nov 14, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants