Repository navigation
fix(cli): surface the capability inspect remedy in --json failures - #198662
Conversation
|
🦞👀 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 an unknown capability ID print its specific error on stderr when JSON output is enabled. Example: Run openclaw capability inspect --name bogus --json.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current diagnostic bug with a focused change and sufficient CLI proof; no actionable defects were found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe infer command tree, also exposed as capability, validates IDs against local metadata and sends failures through the shared CLI runtime and root output renderer. flowchart TD
A[CLI arguments] --> B[Inspect capability metadata]
B --> C[Expected CLI error]
C --> D[Command runtime]
D --> E[Root failure renderer]
E --> F[JSON on stdout]
E --> G[Specific error on stderr]
Technical reviewBest possible solution: Land the existing producer-side error classification fix after required CI succeeds. Do we have a high-confidence way to reproduce the issue? Current-main source shows the plain-error path reaching generic stderr in JSON mode, matching the contributor's supplied before/after CLI output; no target code was executed during this review. Is this the best way to solve the issue? The patch is the smallest complete fix: classify the invalid ID at its existing producer, reuse the shared renderer, and extend the existing regression case. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 11b022e5d9c3. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests -1. Total 0 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:
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 14, 2026, 12:42 AM ET / 05:42 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Proof on the built CLI ( Only difference between lanes ( stdout JSON ( |
|
Landed in 4f20ee5. Thanks @SunnyShu0925. |
|
@obviyus Thanks! |
…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]>
fix(cli): report infer preflight errors through the expected-error path `openclaw infer ... --json` threw plain errors for three checks that run before any request (web fetch disabled, a pinned web fetch provider that is unavailable, and an embedding `--provider` that conflicts with the provider in `--model`), so `--json` stderr showed the generic failure plus the Doctor hint instead of the existing message. The three checks now use the expected-error path with the same messages, following #198662. No new text. Evidence: host, isolated config, no network or provider credentials. Source CLI with --json and in text mode: `infer web fetch --url https://example.invalid` with web fetch disabled, `infer web fetch --url ... --provider nosuch`, and `infer embedding create --provider openai --model voyage/x --text hi`. Base prints the generic failure and Doctor hint, this change prints the existing message; text mode, JSON stdout and exit codes are identical, and neither side made a network call (positive control confirmed the watcher). Vitest-source: four cases fail on base, 118 pass here; typecheck, full build and packed smoke pass. Receipts: #199639 (comment). Thanks @Leon-SK668. Co-authored-by: Ayaan Zaidi <[email protected]>
…law#199639) fix(cli): report infer preflight errors through the expected-error path `openclaw infer ... --json` threw plain errors for three checks that run before any request (web fetch disabled, a pinned web fetch provider that is unavailable, and an embedding `--provider` that conflicts with the provider in `--model`), so `--json` stderr showed the generic failure plus the Doctor hint instead of the existing message. The three checks now use the expected-error path with the same messages, following openclaw#198662. No new text. Evidence: host, isolated config, no network or provider credentials. Source CLI with --json and in text mode: `infer web fetch --url https://example.invalid` with web fetch disabled, `infer web fetch --url ... --provider nosuch`, and `infer embedding create --provider openai --model voyage/x --text hi`. Base prints the generic failure and Doctor hint, this change prints the existing message; text mode, JSON stdout and exit codes are identical, and neither side made a network call (positive control confirmed the watcher). Vitest-source: four cases fail on base, 118 pass here; typecheck, full build and packed smoke pass. Receipts: openclaw#199639 (comment). Thanks @Leon-SK668. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
openclaw capability inspect --name bogus --jsonexits 1 and prints only[openclaw] The CLI command failed.plus[openclaw] For help, run `openclaw doctor`.on stderr, so a script or agent driving the CLI is told nothing about the mistake; the actual reason,Unknown capability: bogus, is trapped in the stdout JSON envelope. Without--jsonthe same command does print the reason.This change routes that one check through the CLI's expected-failure owner, so both output modes print the remedy on stderr.
Error, which the root failure renderer treats as "the CLI command failed", while the text path had already printed the message locallyExpectedCliErrorthrough the existingthrowExpectedCliError()helper, the same owner every other argument guard in this command group usessrc/cli/capability-cli.ts; the existingcapability metadatatest case now also asserts the unknown-id rejection typeWhy This Change Was Made
The root renderer (
src/cli/failure-output.ts) prints the producer's own remedy for expected failures and the generic "command failed / run doctor" pair for everything else.runCommandWithRuntimeprints the message locally only when JSON mode is off, which is why the two lanes disagree for this check today.#198471 converted this command group's argument guards to
throwExpectedCliError()and kept runtime failures on the generic path; validating--nameagainst the capability table is an argument check, so this site belongs with the ones already converted. Fixing it at the producer reuses the existing owner instead of adding a second rendering rule, and keeps the machine-readable envelope byte-identical.Alternatives considered and rejected: special-casing the string in the root renderer (duplicate policy, grows the cold path); leaving it as-is because
--jsonconsumers can read stdout (the remedy then stays invisible in the stream that carries errors, and the text lane keeps contradicting it).Risk is limited to this command's failure formatting. No schema, config, state, or exit-code change; nothing else reaches this throw.
User Impact
openclaw capability inspect --name <id> --jsonnow printsUnknown capability: <id>on stderr alongside the unchanged JSON envelope, so a mistyped or unsupported capability id is self-explanatory in pipelines and agent logscapability listEvidence
Two arms, two lanes, shipped source entry (
node --import ./scripts/tsx.mjs src/entry.ts …) against an isolated state directory, no mocks. BASE isorigin/mainat94cc426fb0b; HEAD is this branch.94cc426fb0b)capability inspect --name bogus— stderrUnknown capability: bogus(271 B)Unknown capability: bogus(271 B, unchanged)capability inspect --name bogus --json— stderr[openclaw] The CLI command failed.+ doctor hint (324 B)Unknown capability: bogus(271 B)capability inspect --name bogus --json— stdoutcapability inspect --name image.edit --json— stdoutcapability list— stdoutBASE, text lane — the remedy is visible:
BASE,
--jsonlane — stderr loses it, only stdout carries it:HEAD,
--jsonlane — the same remedy now reaches stderr, envelope unchanged:Regression test, folded into the existing
it.each(["list", "inspect"])case insrc/cli/capability-cli.test.ts(net −1 test line, no new file):Sibling suites that touch the same renderer and command group, all green on HEAD:
Open PR collision check: re-run against the submission-day open-PR snapshot, both by changed file and by keyword (
capability,ExpectedCliError); no open PR touchessrc/cli/capability-cli.ts,src/cli/expected-cli-error.ts, orsrc/cli/failure-output.ts. The nearest family members in review (#198345, #196073, #191233, #197254, #198333) change other command groups with zero file overlap.What was not tested: no Windows or macOS run, and no real Gateway (this command reads only the local capability table). The repository lint binary could not resolve its JS plugin in the isolated worktree, so
oxlintwas not run locally; formatting was verified with the repo formatter on both changed files.Related: #198471 converted the sibling argument guards in this command group to the same owner; this is the remaining
--namecheck it left on the generic path.