Skip to content

fix(cli): report unknown subcommands instead of excess arguments - #124661

Merged
steipete merged 2 commits into
mainfrom
steipete/cli-unknown-subcommand
Aug 16, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/cli-unknown-subcommand

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users who mistyped a nested CLI command under most command groups saw Too many arguments for this command instead of an unknown-command error. The misleading branch also hid the live group context and command suggestions.

Why This Change Was Made

Commander checks a parent action before its unknown-command branch. Eleven affected groups have a zero-argument parent action for default listing or help, while webhooks and nodes do not; that structural difference caused the inconsistent messages after lazy registration loaded the real command tree.

The OpenClaw Commander adapter now reclassifies only excess-argument errors raised on zero-argument parents with unmatched live child names. Matched leaf commands keep Commander's genuine excess-argument behavior. Suggestion candidates come from the live child tree, including accepted aliases, without adding per-group command lists or making registration eager.

AI-assisted: yes.

Production LOC: +16/-2 (net +14) | Tests: +91/-0

User Impact

Every tested command group now names the invalid subcommand, points at group help and CLI docs, and suggests a nearby real command when one exists. Valid aliases continue to work, and extra arguments after a real leaf command are still reported as extra arguments.

Evidence

13-group built-dist sweep

Group Before After
cron Too many arguments for this command. OpenClaw cron has no command "bogusxyz".
sessions Too many arguments for this command. OpenClaw sessions has no command "bogusxyz".
models Too many arguments for this command. OpenClaw models has no command "bogusxyz".
tasks Too many arguments for this command. OpenClaw tasks has no command "bogusxyz".
devices Too many arguments for this command. OpenClaw devices has no command "bogusxyz".
agents Too many arguments for this command. OpenClaw agents has no command "bogusxyz".
skills Too many arguments for this command. OpenClaw skills has no command "bogusxyz".
plugins Too many arguments for this command. OpenClaw plugins has no command "bogusxyz".
channels Too many arguments for this command. OpenClaw channels has no command "bogusxyz".
config Too many arguments for this command. OpenClaw config has no command "bogusxyz".
memory Too many arguments for this command. OpenClaw memory has no command "bogusxyz".
webhooks OpenClaw webhooks has no command "bogusxyz". unchanged, correct shape
nodes OpenClaw nodes has no command "bogusxyz". unchanged, correct shape

Exact head cc2de5eda1f2349bad09b20262eb6d05605ddab0 built successfully on Blacksmith Testbox tbx_01m05hz0psprsq72s7kw006qh2: https://github.com/openclaw/openclaw/actions/runs/31954845647

Focused built-dist behavior:

$ openclaw sessions lst
OpenClaw sessions has no command "lst".
Did you mean this?
  openclaw sessions list
Try: openclaw sessions --help
Docs: https://docs.openclaw.ai/cli

$ openclaw cron remov
OpenClaw cron has no command "remov".
Did you mean this?
  openclaw cron remove
Try: openclaw cron --help
Docs: https://docs.openclaw.ai/cli

$ openclaw sessions list extra1 extra2
Too many arguments for this command.
Try: openclaw sessions list --help

openclaw cron remove --help also exited successfully, proving the accepted alias remains intact.

Tests and review

  • node scripts/run-vitest.mjs src/cli/program/error-output.test.ts src/cli/program/help.test.ts src/cli/program/build-program.test.ts src/cli/program/parent-default-help.test.ts src/cli/program/action-reparse.test.ts — 45 passed
  • The new lazy-subcommand regression was run against pre-fix production code and failed for the intended reason: received commander.excessArguments, expected commander.unknownCommand.
  • .agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output — clean, no accepted/actionable findings
  • node scripts/check-changed.mjs selected core and coreTests, then stopped on the existing global assertion-safety shrink ratchet (src/gateway/server.auth.control-ui.pairing.suite.ts: 6 < 11) before the selected type/lint fan-out. This PR does not touch that protected baseline.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 16, 2026 15:16
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels Aug 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 11:48 AM ET / 15:48 UTC.

ClawSweeper review

What this changes

The PR changes lazy CLI groups so mistyped nested commands become unknown-command errors with live suggestions, while genuine leaf-command extra arguments remain excess-argument errors.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

No concrete line-level defect was found, but this maintainer-labeled PR needs explicit maintainer review because Commander’s direct contract and exact-head CI could not be independently checked in this checkout.

Priority: P2
Reviewed head: 803a4c854d105ff7aba97ddb66a91af71358ecca
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation and focused tests are coherent, but direct Commander-contract and exact-head CI verification remain unavailable to this review.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-labeled PR is outside the external-contributor proof gate; its body nevertheless provides a prior built-distribution CLI transcript.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-labeled PR is outside the external-contributor proof gate; its body nevertheless provides a prior built-distribution CLI transcript.
Evidence reviewed 7 items Central error owner: The proposed override changes only the inherited Commander error boundary; descendants are also OpenClawCommand instances through createCommand, so loaded groups use the same classification path.
Lazy-group caller path: A placeholder permits excess arguments, replaces itself with the real group, and reparses the original argv; this is the path the new classification targets.
Live suggestion candidates: The final head derives suggestions from the active command’s visible children and includes aliases, avoiding per-group command lists.
Findings None None.
Security None None.

How this fits together

OpenClaw lazily registers CLI command groups, then reparses the original invocation once a group loads. Its Commander adapter turns parser errors into OpenClaw help, documentation links, and command suggestions.

flowchart LR
  A[CLI arguments] --> B[Lazy command group]
  B --> C[Reparsed command tree]
  C --> D{Parser error}
  D -->|Unknown child| E[Unknown-command guidance]
  D -->|Extra leaf arguments| F[Excess-argument guidance]
  E --> G[Operator-visible CLI output]
  F --> G
Loading

Decision needed

Question Recommendation
Should this maintainer-owned CLI error-semantics change land once exact-head CI is green and Commander 15 parent-action behavior is confirmed? Verify and merge: Confirm the Commander 15 contract and exact-head checks, then land the focused CLI repair.

Why: The protected maintainer label requires explicit human handling, and the dependency contract could not be inspected locally.

Before merge

  • Resolve merge risk (P1) - This bug fix adds production +16/-2 (net +14); the centralized error override appears to be the narrow owner boundary, but no net-neutral alternative was established from the available source.
  • Resolve merge risk (P1) - Commander 15 source/types, the two filtered PR comments, and exact-head CI could not be independently read because dependencies are absent and GitHub DNS is unavailable; the earlier built-distribution transcript is supplemental evidence.
  • Complete next step (P2) - The protected maintainer label and unavailable dependency-contract check require human review rather than an automated repair lane.
Agent review details

Security

None.

PR surface

Source +14, Tests +91. Total +105 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 16 2 +14
Tests 1 91 0 +91
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 107 2 +105

Review metrics

Metric Value Why it matters
Production versus regression-test LOC production +16/-2 (net +14); tests +91/-0 The regression suite is focused, while the positive production delta should remain justified by the single shared Commander error boundary.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain one centralized parser-error classification at the OpenClawCommand boundary, then merge only after exact-head CI and Commander 15 behavior are confirmed by a prepared reviewer environment.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain one centralized parser-error classification at the OpenClawCommand boundary, then merge only after exact-head CI and Commander 15 behavior are confirmed by a prepared reviewer environment.

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

No—not independently in this checkout: the source and regression scenario are clear, but dependencies are absent and the supplied built-distribution proof predates the final head.

Is this the best way to solve the issue?

Yes, conditionally: the shared OpenClawCommand error boundary is the narrowest owner for this distinction, pending direct Commander 15 contract confirmation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5f561999a9d8.

Labels

Label justifications:

  • P2: This is a bounded CLI diagnostic correctness repair with limited blast radius and no evidence of data loss, security impact, or runtime unavailability.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-labeled PR is outside the external-contributor proof gate; its body nevertheless provides a prior built-distribution CLI transcript.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame identifies Peter Steinberger for the existing parse-error adapter, and the proposed commits continue work in that same owner boundary. (role: introduced current parse-error path and recent CLI contributor; confidence: high; commits: 81d44365ae2e, ae834e974b79, 803a4c854d10; files: src/cli/program/openclaw-command.ts, src/cli/program/commander-parse-facts.ts, src/cli/program/error-output.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Verify the Commander 15 parent-action/excess-argument contract in a prepared checkout.
  • Confirm required checks on head 803a4c8.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-16T15:22:14.137Z sha cc2de5eda1f2349bad09b20262eb6d05605ddab0 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-16T15:33:12.722Z sha 199396b0e8bd8bc5986c1280d364f1138223836d :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 16, 2026
@steipete
steipete force-pushed the steipete/cli-unknown-subcommand branch from 199396b to 803a4c8 Compare August 16, 2026 15:42
@steipete
steipete merged commit 76f4b94 into main Aug 16, 2026
212 checks passed
@steipete
steipete deleted the steipete/cli-unknown-subcommand branch August 16, 2026 15:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 17, 2026
…nclaw#124661)

* fix(cli): report unknown subcommands accurately

* style(cli): avoid map spread when collecting child command names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

1 participant