Skip to content

fix(cli): show the reason for invalid numeric flag values - #189993

Merged
obviyus merged 11 commits into
openclaw:mainfrom
jerome-queck:fix/cli-numeric-flag-reasons
Nov 2, 2026
Merged

obviyus merged 11 commits into
openclaw:mainfrom
jerome-queck:fix/cli-numeric-flag-reasons

Conversation

@jerome-queck

@jerome-queck jerome-queck commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #189962. Includes the diagnostic-only fix from #190053, preserving yxshee's original commit and credit alongside Jerome's original #189993 work.

Existing numeric-option validation and rejected pairing inputs lose their specific explanations behind the root CLI's generic failure output. Classify those already-authored diagnostics as ExpectedCliError, without changing accepted inputs, parsing, messages, defaults, JSON payloads or approval behavior.

Why This Change Was Made

Move the unchanged error class/helper into a dependency-light owner and migrate production callers, preserving the native CLI bootstrap import boundary. Keep the probe parser in its existing owner and repair the root-dispatch regression expectation. No new flags, public API, model-facing behavior, pairing approval logic, permissions or credential handling changes.

Explicitly approved internal re-export exception

Retain the contributor's one-line ExpectedCliError re-export in src/cli/failure-output.ts for the unchanged src/cli/plugins-cli.marketplace-entries.test.ts import. Ayaan explicitly approved this shim as an exception to the usual complete-cutover rule. All production constructor consumers use the dependency-light owner directly; this re-export preserves the same constructor identity and adds no wrapper or alternative implementation.

This is necessary because the ClawSweeper input scanner stages the complete merge-base and head blobs of changed paths, plus their patch; it does not scan only added lines. The marketplace test contains a pre-existing credential-shaped synthetic URL fixture. Its blob is identical on the PR and current main (9b890becdad73b93cd4ffb5e3bcd63c5952aacae). Touching its import brings that complete base blob into the scan and caused the documented refusals. Rebasing or merging current main would not remove that fixture, and splitting or renaming the file still includes its old base blob because scanner collection disables rename detection.

The retained re-export keeps this unrelated fixture-bearing test outside the introduced diff. No fixture assertions are removed, and no scanner, scanner policy, allowlist or ClawSweeper code is changed. The contributor's export-only adjustment is retained through the current-main refresh; no history rewrite was used.

Evidence

Current head 8df5698fb6a632b09f05774f77ea8b15f3dcf9d1 merges freshly fetched main d0177edd6c8dc3307721f0abd7f41eef7a13dd9f. Fresh merged-head proof: full candidate build, 116 passing focused tests across six files, and a shipped logs --limit abc check that prints the specific reason and exits 1. The stale exec-policy, update-helper and model-status callers all retain imports from the dependency-light error owner.

Retained original before-and-after matrix:

Secretless node:24.22.1 Docker; shipped built CLI on main 1f4a08f7925f2a7267fe9e1a69dccb6d53428830 and candidate 9acff964347cddb0a2d459c7560b89f0dd07ff56, explicit isolated profiles/config/state. Each invalid case runs twice on each ref.

Case Main Candidate
Numeric invalid inputs 24 generic failures 24 specific reasons
Pairing rejected input/empty-store cases 18 generic failures 18 specific reasons/hints
Valid numeric controls 4 pass 4 pass
Valid empty-store pairing listing controls 3 pass 3 pass

Numeric JSON payloads unchanged in 10 comparisons; pairing JSON unchanged in four comparisons after profile-name normalization. All rejected cases exit 1. Pairing fixtures seed no pending requests and perform no successful approvals; rejected calls leave config unchanged.

The previous contributor head 52898b70f83af97c489080f2fefaec66615d1606 added only the retained re-export and corresponding test-import restoration to that proved candidate. It received a fresh 5/6 review with no findings after the explicit shim exception and literal-only discussion redaction. The current merge preserves those commits; the new candidate check above is separate from, and does not claim to replay, the full original matrix.

200 focused checks pass across 12 files in the retained proof. Counterfactual main runs reproduce eight numeric classification failures and one pairing classification failure. The full candidate build includes the CLI bootstrap guard. The earlier pushed CI failure was the stale root-dispatch expectation; the corrected file passes all 17 tests.

Detailed built-CLI capture. Historical scanner refusal. This does not claim to fix the separate live pairing approval timeout issue.

Net production lines +6, tests -2, docs +7 against the merge base. No CHANGELOG edits.

Merge Danger

Two-way door: reverting restores the previous diagnostic presentation. No persisted-state migration, approval-policy change or accepted-input change. Blast radius is expected-error rendering for the existing CLI validators; the retained internal re-export points to the same constructor.

@clawsweeper

clawsweeper Bot commented Nov 1, 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 commands Command implementations size: S labels Nov 1, 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Classify existing numeric-option and pairing input errors as expected CLI failures so their explanations reach users.

Example: Run openclaw logs --limit abc.

  • Before: The CLI prints “The CLI command failed.” without explaining the invalid value.
  • After: The CLI prints “--limit must be a positive integer.” and exits 1.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused, source-verified repair with shipped-entry-point proof, preserved contracts, and no actionable findings; CI disposition remains separate from code quality.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Supplied terminal output exercises built openclaw.mjs in secretless Docker with isolated state, showing specific numeric and pairing rejection guidance, unchanged JSON and exit codes, valid controls, and no config changes after rejected approvals; the reviewed head adds a fresh built-CLI diagnostic check and build validation.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Invalid numeric flags and rejected pairing inputs hide their existing explanation behind a generic CLI failure.
Reason: Restores authored recovery guidance without changing accepted values, defaults, JSON contracts, or approval behavior; the retained re-export has explicit collaborator approval.

Merge readiness

✅ Ready for maintainer review

This PR fixes current CLI diagnostic failures with relevant shipped-CLI proof and no identified code defects; required CI remains unresolved.

Priority: P2
Reviewed head: 8df5698fb6a632b09f05774f77ea8b15f3dcf9d1

Before merge

None.

Findings

None.

Agent review details

How this fits together

CLI validators turn command arguments into values or errors, and the shared root renderer converts those errors into human diagnostics and JSON failure envelopes.

flowchart TD
A[CLI arguments] --> B[Existing validators]
B --> C[Valid command dispatch]
B --> D[Expected CLI error]
D --> E[Shared root renderer]
E --> F[Stderr guidance and JSON output]
Loading

Technical review

Best possible solution:

Land the producer-side classification repair using the shared dependency-light error constructor and the explicitly approved re-export.

Do we have a high-confidence way to reproduce the issue?

Current-main validators and root rendering establish the failure mechanism, corroborated by supplied built-CLI before/after output; this read-only review executed no target code.

Is this the best way to solve the issue?

The smallest complete fix classifies known failures at existing producers, preserves parsing and authority checks, and extracts the unchanged error type to satisfy the bootstrap import boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6842bb579adb.

Provenance checked

  • Expected-error constructor and shared helper keeps the original intent (d3447df: Separate actionable command guidance from unexpected failures; later commits added matches, causes, and the shared throwing helper, all preserved by the extraction.)
  • Strict numeric parsing and caller-specific timeout guidance keeps the original intent (ddb83ed: Consolidate strict integer validation without changing grammar or defaults; timeout guidance from 878de19 must retain each caller's accepted flag.)
  • Private model probe parser keeps the original intent (6725e57: Consolidate the command's finite-number and positive-integer validation while preserving their distinct grammar; the parser remains private and only its error classification changes.)
  • Pairing validation and device redirect keeps the original intent (938cc36: Provide actionable input guidance; fix(cli): stop pairing list crashing with empty channel enum #98142 later added the device redirect, and subsequent account and live-owner protections remain intact.)
  • Concise unexpected-error rendering keeps the original intent (d0b48d6: Keep internal diagnostics optional while retaining useful recovery guidance; known validation failures now use the existing expected-error distinction.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 2fcecdb adds src/cli/pairing-cli.ts:103 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2fcecdb92e69; files: src/cli/pairing-cli.ts)
  • Vincent Koc: Raw commit 23d5e63 adds src/cli/parse-timeout.ts:21 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 23d5e630cd9a; files: src/cli/parse-timeout.ts)
  • Ayaan Zaidi: Raw commit 878de19 adds src/cli/parse-timeout.ts:27 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 878de19f4214; files: src/cli/parse-timeout.ts)

PR surface

Source +6, Tests -2, Docs +7. Total +11 across 62 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 34 85 79 +6
Tests 26 70 72 -2
Docs 2 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 62 162 151 +11

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Hidden validation explanations cause avoidable confusion in operator CLI workflows without demonstrating a broken approval or provider operation.
  • 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 (3 earlier review cycles)
  • reviewed 2026-11-01T03:04:43.591Z sha 4478d06 :: needs changes before merge. :: [P2] Keep the probe parser private to its existing command owner
  • reviewed 2026-11-01T10:12:55.682Z sha 52898b7 :: needs changes before merge. :: [P3] Finish migrating the remaining test instead of retaining the old export
  • reviewed 2026-11-02T01:35:08.676Z sha 52898b7 :: needs maintainer review before merge. :: none

Reviewed November 1, 2026, 8:55 PM ET / November 2, 2026, 01:55 UTC (Revision 4).

@obviyus

obviyus commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Built CLI comparison

Main 1f4a08f7925f2a7267fe9e1a69dccb6d53428830 versus candidate 0e5bbe7e67841fd267f8df6627b92b9c8a362c3d, secretless Linux arm64 Docker, Node 24.22.1. Both used the shipped built openclaw.mjs entry and task-owned profiles. Native CLI queries verified the config, state and database paths before the runs; the candidate reported OpenClaw 2026.10.9 (0e5bbe7).

Each command/value combination below ran twice on each ref:

logs --limit abc
logs --limit 0
logs --max-bytes abc
logs --interval abc
devices list --timeout abc
status --json --timeout abc
channels status --json --timeout abc
models status --json --probe-timeout abc
models status --json --probe-concurrency abc
models status --json --probe-max-tokens abc
channels status --timeout abc
models status --probe-timeout abc
Accepted comparison                  main       candidate
Invalid invocations                  24         24
Generic failure on stderr            24          0
Flag + accepted values on stderr      0         24
Exit status                           1          1
Valid-number controls passing         4          4
Machine failure envelopes compared   10         10 (identical)

Actual candidate stderr examples:

$ openclaw logs --limit abc
--limit must be a positive integer.
[exit 1]

$ openclaw devices list --timeout abc
Invalid --timeout. Use a positive millisecond value, e.g. --timeout 30000. Received: "abc".
[exit 1]

$ openclaw models status --json --probe-timeout abc
--probe-timeout must be a positive number.
[exit 1; unchanged JSON failure envelope on stdout]

Valid controls were built CLI log reads with limit 2 / max-bytes 10000 / interval 1000; device and channel reads with timeout 10000; and model status with fractional probe timeout 1.5, concurrency 2 and max tokens 8. All exited zero and retained their expected JSON/JSONL formats. Gateway-backed controls used a real isolated built Gateway, not a transport stub. No model inference, paid provider or live account was involved.

Review-scope correction: at this pinned main, text-mode channels/models status also reproduced generic stderr. A debug-only diagnostic capture showed the shipped tryRouteCli fast route calling the command directly, bypassing the Commander wrapper discussed in the issue review. The fix remains at the same numeric producers and changes no channel-message or model-facing path. Initial harness expectations about that text route and log JSONL framing were corrected before the accepted comparison; those setup assertions are not product verdicts.

Build/import proof: the full candidate build passed, including native declarations, the CLI bootstrap import guard and Plugin SDK export checks. An initial import of the full failure renderer from the timeout parser correctly tripped the native-hook-relay guard on AI diagnostics. The final fix moves the unchanged expected-error constructor/helper to a runtime-dependency-free module and migrates creators, without widening the guard or retaining a compatibility re-export. The probe parser stays inline; duplicate helper-only tests were consolidated into existing owners.

Focused checks: 171 passing tests across numeric classification, root formatting, CLI process exits, bootstrap/native relay behavior, plugin CLI error identity and lazy command policy. Changed-file lint/format passed. The producer regressions replayed against main gave 8 intended classification failures / 47 passes. Whole-PR delta: production +3, tests −2, documentation +4. The reporter's original commit is preserved.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M and removed size: S labels Nov 1, 2026
@obviyus

obviyus commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 1, 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026
@jerome-queck

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. label Nov 1, 2026
obviyus added a commit that referenced this pull request Nov 2, 2026
fix(cli): show existing specific errors instead of the generic CLI failure

Some CLI commands already had a specific error reason, but the root CLI replaced it with the generic "The CLI command failed." output. These existing diagnostics are now raised as `ExpectedCliError`, the same way as #189993, so users see the specific reason. The message text and the exit code (1) are unchanged, and success and JSON output are unchanged.

This sweep includes #191225 and #191219, with yxshee's commits kept for credit.

Evidence: built CLI in secretless Node 24.22.1 Docker. All six failure paths showed the generic failure on main twice and the existing specific reason with this change twice, with exit code 1. Six success and JSON controls were unchanged. Details: #191295 (comment).

Thanks @yxshee.

Co-authored-by: yxshee <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
Align the capability command fixtures with ExpectedCliError propagation after openclaw#189993. Keep exact human and machine diagnostics and all pre-dispatch rejection checks. Retain blank video duration in the existing duration table.

The original Bun replay fails three assertions. The repaired complete file passes all 102 tests on pinned Bun 1.4.4 and Node 24.22.1; the real CLI exits 1 with canonical diagnostics for all three invalid inputs. Five additional assertion lines preserve the error boundary contract.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
The ExpectedCliError migration in openclaw#189993 intentionally prints the invalid timeout reason to stderr. Align the five real status/health CLI cases with that diagnostic while preserving exact JSON, exit status, flag ordering, forced Commander, and TTY restoration checks.

Reproduced all five obsolete assertions on the base. Fixed full-file proof: 29 passed on Node 24.22.1 (28.97s Vitest, 45.618s wall). Targeted typecheck, lint, format, and diff checks pass. No production changes or test-line growth.

Failure evidence: https://github.com/openclaw/openclaw/actions/runs/41383453205/job/125080813156
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
…law#191295)

fix(cli): show existing specific errors instead of the generic CLI failure

Some CLI commands already had a specific error reason, but the root CLI replaced it with the generic "The CLI command failed." output. These existing diagnostics are now raised as `ExpectedCliError`, the same way as openclaw#189993, so users see the specific reason. The message text and the exit code (1) are unchanged, and success and JSON output are unchanged.

This sweep includes openclaw#191225 and openclaw#191219, with yxshee's commits kept for credit.

Evidence: built CLI in secretless Node 24.22.1 Docker. All six failure paths showed the generic failure on main twice and the existing specific reason with this change twice, with exit code 1. Six success and JSON controls were unchanged. Details: openclaw#191295 (comment).

Thanks @yxshee.

Co-authored-by: yxshee <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 3, 2026
… when the flag comes before the subcommand (#190366)

fix(cli): show existing hooks validation errors instead of the generic failure



Two `hooks` command validations already had specific error messages, but the root CLI replaced them with the generic "The CLI command failed." output. These validations now raise `ExpectedCliError`, the same way as #189993 and #191295, so users see the specific reason. The message text, exit code (1) and JSON envelopes are unchanged.

Evidence: built CLI in secretless Node 24.22.1 Docker. Both validations showed the generic failure on main twice and the specific reason with this change twice, with exit code 1. Valid parent and leaf invocations, JSON output and the existing leaf diagnostic were unchanged. Details: #190366 (comment).

Thanks @yxshee.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 4, 2026
… when the flag comes before the subcommand (openclaw#190366)

fix(cli): show existing hooks validation errors instead of the generic failure



Two `hooks` command validations already had specific error messages, but the root CLI replaced them with the generic "The CLI command failed." output. These validations now raise `ExpectedCliError`, the same way as openclaw#189993 and openclaw#191295, so users see the specific reason. The message text, exit code (1) and JSON envelopes are unchanged.

Evidence: built CLI in secretless Node 24.22.1 Docker. Both validations showed the generic failure on main twice and the specific reason with this change twice, with exit code 1. Valid parent and leaf invocations, JSON output and the existing leaf diagnostic were unchanged. Details: openclaw#190366 (comment).

Thanks @yxshee.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 5, 2026
…ain is configured (#192127)

fix(dns): show existing errors from dns setup guards

`openclaw dns setup` guards threw plain errors, so their existing messages were hidden behind a generic CLI failure. They now use the existing expected-CLI-error path and show the same messages, as #189993 did for other commands. Exit codes are unchanged, and there is no change to DNS domains, defaults, zones or subprocesses.

Evidence: built Linux CLI, twice per ref. For a missing domain, an invalid domain, and `--apply` on Linux, main printed generic failures; with this change the existing messages are printed with exit 1. Plan-only output is unchanged, with no brew or sudo calls, zone creation, CoreDNS installation or config rewrites. The macOS tailnet guard is covered by unit tests only. Details: #192127 (comment).

Thanks @yxshee.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…ain is configured (openclaw#192127)

fix(dns): show existing errors from dns setup guards

`openclaw dns setup` guards threw plain errors, so their existing messages were hidden behind a generic CLI failure. They now use the existing expected-CLI-error path and show the same messages, as openclaw#189993 did for other commands. Exit codes are unchanged, and there is no change to DNS domains, defaults, zones or subprocesses.

Evidence: built Linux CLI, twice per ref. For a missing domain, an invalid domain, and `--apply` on Linux, main printed generic failures; with this change the existing messages are printed with exit 1. Plan-only output is unchanged, with no brew or sudo calls, zone creation, CoreDNS installation or config rewrites. The macOS tailnet guard is covered by unit tests only. Details: openclaw#192127 (comment).

Thanks @yxshee.

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 commands Command implementations docs Improvements or additions to documentation 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: M 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.

[Bug]: invalid --limit/--max-bytes/--interval/--timeout/--probe-timeout values print only a generic 'The CLI command failed.' with no reason

3 participants