Repository navigation
fix(cli): show directory failure remedies alongside JSON - #199616
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 directory-owned validation and unsupported-operation errors readable on stderr when JSON output is enabled. Example: Run openclaw directory groups members --group-id ' ' --json.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR is ready for landing: the focused fix preserves the existing JSON contract, supplied CLI proof covers the changed paths, and exact-head CI is green. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe directory CLI resolves channel capabilities and performs lookups; its failures reach the shared CLI boundary, which owns JSON stdout, stderr diagnostics, and failure exit status. flowchart TD
A[Directory CLI invocation] --> B[Directory validation and capability guards]
B --> C[Expected CLI error]
B --> D[Plugin lookup]
D --> E[Successful directory output]
C --> F[Shared root failure renderer]
F --> G[JSON stdout and readable stderr]
Technical reviewBest possible solution: Land the existing four-guard classification repair while retaining the shared renderer and unchanged plugin-error handling. Do we have a high-confidence way to reproduce the issue? Current-main source shows the failure path, and supplied before/after CLI receipts reproduce it on a baseline whose directory files match fetched main; this read-only review ran no target code. Is this the best way to solve the issue? This is the smallest complete fix: classify directory-owned failures with the existing helper, preserve root rendering ownership, and leave unexpected plugin failures untouched. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d32ac41084fc. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests 0. Total +1 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 15, 2026, 10:36 AM ET / 15:36 UTC (Revision 2). |
|
Validated head All final checks ran on the host through ocx. Host-execution check: the merge-base diff touches only Before / afterBaseline: vitest-source: the same consolidated source: Candidate stderr, with the existing text unchanged:
JSON stdout was byte-identical on both sides for every case. Example: {"ok":false,"error":{"type":"cli_error","message":"Missing --group-id"}}Controls passed:
The four failing paths stop before directory lookup. Successful controls use IRC's configuration-backed directory, not an IRC connection. No live-channel behavior is claimed. Packaging and scopefull: The matching test typecheck leaf ( Simplification combined unsupported-capability text/JSON coverage and removed a duplicate shared list-guard case, retaining blank-ID-before-write, missing-plugin and unexpected-plugin-error coverage. Whole-PR deltas: production +5/-4, tests +26/-26 (net 0); no allocation file. No new message text. No host hooks ran: Worktrunk used This is reversible error classification only: no lookup, configuration, persistence or plugin capability changes. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review The prior request was superseded before review admission. Head 2a2066d, PR description and proof are now final; exact-head CI and openclaw/ci-gate are green. Please review this current tuple. |
|
🦞👀 Re-review progress:
|
|
Landed in 285a326. Thanks @Leon-SK668. |
…9616) fix(cli): report directory input errors through the expected-error path `openclaw directory ... --json` threw plain errors for four input checks ("Unsupported channel: X", "Missing --group-id", "Channel X does not support ..." and "... does not support directory self"), so `--json` stderr showed the generic failure plus the Doctor hint instead of the existing message. The four checks now use the expected-error path with the same messages. All four run before any directory lookup; no new text. Evidence: host, isolated state and fake config, no network or credentials. Source CLI, 14 cases with `--json` and in text mode (including a blank `--group-id ' '`; omitting the option entirely stops at Commander's required-option check on both, unchanged): base prints the generic failure and Doctor hint, this change prints the existing message; text mode, JSON stdout and exit codes are identical. Vitest-source: 5 cases fail on base, 21 pass here. Typecheck, full build and packed-entry smoke pass. Receipts: openclaw#199616 (comment). Thanks @Leon-SK668. Co-authored-by: Ayaan Zaidi <[email protected]>
Maintainer validation on
2a2066dc0914ca62392bc8678a5d2d231864eef0: before/after receipts. All four guards reproduced through the real CLI; stdout, text-mode diagnostics and exit codes stayed unchanged. Focused tests: baseline 5 intended failures, candidate 21 passed; test typecheck, full build and offline packed-entry smoke passed. Consolidated tests are net 0 lines (+26/-26); production remains +5/-4. Original contributor commit retained.What Problem This Solves
Fixes:
directory --jsonhides the actionable reason on stderr for a blank group ID or an unavailable lookup operation, even though JSON stdout already contains that reason.User Impact
Operators keeping stdout for a JSON consumer also receive the existing error message on stderr. The error JSON, exit codes, human-mode messages and successful lookup output stay the same. No configuration, default, protocol or channel capability changes.
Why This Change Was Made
The directory command produced ordinary errors for its own validation and unsupported-operation guards. The root JSON error handler deliberately hides ordinary failures. Use the existing expected-error helper at these four guards, covering self, peers, groups and members at their shared owner. Unexpected errors thrown by plugins retain their original classification.
Evidence
c0166c3and head48b9240:node community-directory-native-proof-20261115.mjs CHECKOUT PHASE; PHASE changes assertions only, all six native CLI inputs and fixture bytes identicalNative runtime build:
node --import ./scripts/tsx.mjs scripts/build-all.mts sourcePerformancepassed on the committed head in 231.8s. This is the native CLI runtime build, not full release/package validation. The focused suite passed 23/23; its 173.20s cold run was dominated by the repository's compiler preparation. Upstream CI will be read after PR creation.Actual native before/after stream readback (synthetic, isolated IRC configuration)
Base:
c0166c395cf81095f431808c9496cb6022ad4387, captured 2026-11-15T12:53:56.305Z.Head/build commit:
48b92409887ac4e7b8c67883918a3fee2d9250c9, captured 2026-11-15T13:01:56.173Z.Node:
v24.22.1; Linux. The same driver, fixture and six native commands ran on both builds. Only the driver's expected red/green assertions differ.[ { "args": "directory groups members --group-id ", "base": { "exit": 1, "stdout": "", "stderr": "Missing --group-id" }, "head": { "exit": 1, "stdout": "", "stderr": "Missing --group-id" } }, { "args": "directory groups members --group-id --json", "base": { "exit": 1, "stdout": "{\n \"ok\": false,\n \"error\": {\n \"type\": \"cli_error\",\n \"message\": \"Missing --group-id\"\n }\n}", "stderr": "[openclaw] The CLI command failed.\n[openclaw] For help, run `openclaw doctor`." }, "head": { "exit": 1, "stdout": "{\n \"ok\": false,\n \"error\": {\n \"type\": \"cli_error\",\n \"message\": \"Missing --group-id\"\n }\n}", "stderr": "Missing --group-id" } }, { "args": "directory groups members --group-id #proof --channel irc", "base": { "exit": 1, "stdout": "", "stderr": "Channel irc does not support group members listing" }, "head": { "exit": 1, "stdout": "", "stderr": "Channel irc does not support group members listing" } }, { "args": "directory groups members --group-id #proof --channel irc --json", "base": { "exit": 1, "stdout": "{\n \"ok\": false,\n \"error\": {\n \"type\": \"cli_error\",\n \"message\": \"Channel irc does not support group members listing\"\n }\n}", "stderr": "[openclaw] The CLI command failed.\n[openclaw] For help, run `openclaw doctor`." }, "head": { "exit": 1, "stdout": "{\n \"ok\": false,\n \"error\": {\n \"type\": \"cli_error\",\n \"message\": \"Channel irc does not support group members listing\"\n }\n}", "stderr": "Channel irc does not support group members listing" } }, { "args": "directory peers list --channel irc --json", "base": { "exit": 0, "stdout": "[\n {\n \"kind\": \"user\",\n \"id\": \"alice\"\n }\n]", "stderr": "" }, "head": { "exit": 0, "stdout": "[\n {\n \"kind\": \"user\",\n \"id\": \"alice\"\n }\n]", "stderr": "" } }, { "args": "directory groups list --channel irc --json", "base": { "exit": 0, "stdout": "[\n {\n \"kind\": \"group\",\n \"id\": \"#proof\",\n \"name\": \"#proof\"\n }\n]", "stderr": "" }, "head": { "exit": 0, "stdout": "[\n {\n \"kind\": \"group\",\n \"id\": \"#proof\",\n \"name\": \"#proof\"\n }\n]", "stderr": "" } } ]The peer and group controls use IRC's existing configuration-backed directory implementation, without a live IRC connection. Both runs compared config bytes before/after. No live channel support or external-provider behavior is claimed.
Complete reproducible native driver
Save as
community-directory-native-proof-20261115.mjs, then run with Node 24.22.1 against a successfully built checkout:node community-directory-native-proof-20261115.mjs CHECKOUT redon the base, and the same command withgreenon the head. SHA256:03ecaf662f8345169836ffaa3fe5d8a93368c3cad4dd3503ce979bbd319b4846. It launches the built CLI; the directory owner, plugin loader and root formatter are not replaced.AI-assisted: implemented with Codex; the commands and native stream readbacks above were executed locally.