Repository navigation
fix(hooks): hooks --agent errors print only "The CLI command failed." when the flag comes before the subcommand - #190366
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 preserves specific validation reasons when hooks receives an invalid parent --agent option. Example: Run openclaw hooks --agent ' ' list.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current diagnostic bug with a focused change and convincing built-CLI proof; no actionable defects were found, and CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCommander validates hooks options before dispatch; expected errors reach the root CLI renderer, which produces human stderr and optional JSON failure output. flowchart TD
A[Hooks CLI arguments] --> B[Commander parent validation]
B --> C[Shared hooks failure formatter]
C --> D[Expected CLI error]
D --> E[Root failure renderer]
E --> F[Human stderr and JSON stdout]
Technical reviewBest possible solution: Land the existing error-classification fix once the required checks pass. Do we have a high-confidence way to reproduce the issue? Current-main source shows both plain errors bypassing the hooks wrapper, and the supplied built-CLI comparison reproduces both generic failures on the baseline. Is this the best way to solve the issue? This is the smallest complete fix: classify both refusals through the existing expected-error owner while sharing the established hooks formatter. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d921a2bfcc4e. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +6, Tests -1, Docs +4. Total +9 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label 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 3, 2026, 1:37 AM ET / 06:37 UTC (Revision 2). |
Independent built-CLI hooks validation proofFinal head: Integrated current main because #189993 had moved the shared ExpectedCliError class to its dependency-light owner in the touched files. The built candidate includes that owner; the final follow-on commit changes only test consolidation and documentation. No dependency, policy, or public API change. No new diagnostic wordingBoth validation strings below already exist on main, unchanged. The Shipped-command comparisonIndependently built runtime artifacts in secretless Linux arm64 Node v24.22.1 Docker. Each run has fresh task-owned profile/home/config/state/workspace, an explicit main agent and synthetic owner profile. The built CLI confirms its configuration path. No Gateway, external provider, paid service or contributor code runs on the host. For each affected validation, main twice prints the generic root failure; candidate twice prints the existing reason; exit remains 1: The same four before/after comparisons were also run with parent {"ok":false,"error":{"type":"cli_error","message":"--agent must not be blank"}}For unsupported install, ControlsAcross main1/main2/candidate1/candidate2:
Successful report comparison normalizes only independently created fixture-root and build-artifact paths; all other JSON, stderr and exit fields compare equal across all four runs. Config bytes remain unchanged in each run and the rejected install creates no hook-pack path. Focused checks and simplification
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
… 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]>
…e2e (#192621) #190366 made hooks --agent "" print its own error; this e2e case still expected the generic failure. Co-authored-by: obviyus <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…e2e (openclaw#192621) openclaw#190366 made hooks --agent "" print its own error; this e2e case still expected the generic failure. Co-authored-by: obviyus <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
openclaw hooks --agent <id> <subcommand>hides the existing validation reason behindThe CLI command failed.when the parent agent is blank or the subcommand does not accept it. Equivalent leaf-option errors already display their reason.User Impact
Both parent preAction failures now print their existing specific diagnostic. Exit codes remain 1 and JSON error envelopes are unchanged. Valid invocations and leaf-option diagnostics retain their current behavior.
Why This Change Was Made
Factor the existing hooks failure formatter unchanged and raise the existing dependency-light ExpectedCliError class from the two preAction checks. Those checks run outside the action wrapper, so plain Error incorrectly reaches the generic root renderer.
No new production message wording, dependency, public API, policy, configuration or storage behavior. This reuses the owner introduced by #189993, following #191295's expected-condition classification pattern. Current main was integrated for that touched-owner move, not merely because it advanced.
Original fix by @yxshee; their original commit is retained.
Evidence
Independently built main
19fc93a4f2ac85acd6e5f0986e1f461816a912ceand the main-integrated candidate in secretless Linux arm64 Node 24.22.1 Docker, using fresh isolated profiles/config/state/workspaces.hooks --json: identical failure JSON and existing raw messages; only human stderr framing changes.hooks list --jsoninvocations exit 0, have clean stderr and return unchanged complete reports after normalizing only fixture/artifact paths. Blank leaf-agent control remains unchanged, including exit 1 and exact diagnostic.Detailed captured output and controls: independent proof comment.
Merge Danger
Two-way door: reverting restores the previous error classification; no migration or persistent-format change. Blast radius is human error framing for invalid parent hooks
--agentusage and reuse of the existing hooks formatter. Command admission, successful behavior, exit statuses, JSON messages and sanitization policy remain unchanged.