Repository navigation
fix(cli): show system event remedies alongside JSON - #199670
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 routes two system-event argument errors through the existing CLI failure renderer so JSON callers also receive stderr guidance. Example: Run
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still suppresses these stderr remedies, and this focused, validated repair introduces no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe system CLI validates event arguments before Gateway RPC; expected errors pass through its wrapper to the root renderer, which produces JSON stdout and human stderr. flowchart TD
A[System event command] --> B[Local argument validation]
B --> C[Expected CLI error]
C --> D[Root failure renderer]
D --> E[JSON stdout]
D --> F[Remedy on stderr]
B --> G[Valid event Gateway RPC]
Technical reviewBest possible solution: Use the existing expected-error classifier at both local guards and retain the shared root renderer as the sole failure-output owner. Do we have a high-confidence way to reproduce the issue? Current-main source explains the empty stderr for invalid mode and whitespace-only text, and supplied real CLI before/after captures demonstrate both failures; no target code was executed during this review. Is this the best way to solve the issue? The patch is the smallest complete repair: classify the two producer-owned argument errors and reuse the existing wrapper handoff and root output contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8b94cfb556c3. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
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, 12:43 PM ET / 17:43 UTC (Revision 2). |
|
Validated final head Observed user-path resultTier: source, host through Commands exercised once on each side: Both were also run without
All eight executions exited 1. Both text-mode diagnostics and stdout were byte-identical across sides. Both JSON stdout envelopes were also byte-identical; only the missing stderr diagnostic was restored. Selected JSON stdout, unchanged: {
"ok": false,
"error": {
"type": "cli_error",
"message": "--mode must be now or next-heartbeat"
}
}Identical stdout SHA-256 on main and candidate:
No Gateway connectionNo Gateway was started. The isolated config and explicit Focused checks and simplification
Merge danger: reversible code/test change. Blast radius: stderr presentation of the two local system-event validation failures. Full package and host eligibility
Hosted gates on the final head
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in b2b3b42. Thanks @Leon-SK668. |
fix(cli): report system event argument errors through the expected-error path
`openclaw system event --json` with an invalid `--mode` or a whitespace-only `--text` exited 1 with the JSON failure on stdout but left stderr without the existing message ("--mode must be now or next-heartbeat" / "--text is required. ..."). Both checks run before any Gateway call and now use the expected-error path with the same messages. No new text.
Evidence: host, isolated state, no Gateway. Source CLI: `system event --text hello --mode later` and `system event --text ' '`, with --json and in text mode: base leaves stderr without the message, this change prints the existing message; JSON stdout, text output and exit 1 are byte-identical, and neither side opened a Gateway connection. Vitest-source: two cases fail on base, 6 pass here; typecheck, full build and packed-install smoke pass. Receipts: openclaw/openclaw#199670 (comment).
Thanks @Leon-SK668.
Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks @obviyus for tightening the tests and checking both output modes before landing this. |
fix(cli): report system event argument errors through the expected-error path
`openclaw system event --json` with an invalid `--mode` or a whitespace-only `--text` exited 1 with the JSON failure on stdout but left stderr without the existing message ("--mode must be now or next-heartbeat" / "--text is required. ..."). Both checks run before any Gateway call and now use the expected-error path with the same messages. No new text.
Evidence: host, isolated state, no Gateway. Source CLI: `system event --text hello --mode later` and `system event --text ' '`, with --json and in text mode: base leaves stderr without the message, this change prints the existing message; JSON stdout, text output and exit 1 are byte-identical, and neither side opened a Gateway connection. Vitest-source: two cases fail on base, 6 pass here; typecheck, full build and packed-install smoke pass. Receipts: openclaw#199670 (comment).
Thanks @Leon-SK668.
Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
openclaw system event --text hello --mode later --jsonexits1 and writes the correct JSON failure, but stderr is empty. Operators watching stderr while stdout is captured miss the existing corrective message. A whitespace-only--texthas the same problem.Why This Change Was Made
Classify both existing local argument refusals with
throwExpectedCliError. The System wrapper already rethrows classified errors, and the root failure renderer already owns their JSON and human diagnostics. Reuse those owners instead of adding another renderer or changing broad error handling.This follows the accepted Directory diagnostic repair in #199616 while preserving the structured-stdout repair in #123614. Existing-solutions preflight: the existing classifier and root renderer cover the requirement; no new library, plugin or custom output system.
User Impact
JSON callers retain the same parsed failure envelopes/messages and exit1 while stderr also explains how to correct the arguments. Human refusals remain readable with empty stdout. Validation order, accepted modes, defaults, session-key normalization, RPC payloads, Gateway rejection/transport handling, heartbeat and presence are unchanged.
Two files: production +3/-2 (net1 import), tests +14/-9 (net5). The test replaces the old invalid-mode case with one compact table covering both local guards. No config/default, protocol/schema, dependency, persistence, auth or permission change. The deliberate visible change is actionable stderr for these two existing JSON-mode refusals.
Evidence
48b92409887ac4e7b8c67883918a3fee2d9250c9at 2026-11-15T15:48:19.293Z; GREEN99379fa9a644f765c48d07df4cae79332dafbc91at 2026-11-15T16:07:23.107Z. The final build commit equals the contributor head.d3f4f94fbb46e216c9a88555469127518532b4b9. Fresh live main/owner/contract comparison also matched before commit.OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/cli/system-cli.test.ts src/cli/failure-output.test.ts --maxWorkers=1 --reporter=dot: 27 passed, exit0;147.45s Vitest/159.13s wrapper. Existing Gateway rejection, agent-selection, valid event dispatch and cancellation consumers remain covered.tsgo, typedoxlint,oxfmtandgit diff --checkpass. The external two-file type probe extends the repository test tsconfig and includes ambient declarations; no test/type baseline changed.node --import ./scripts/tsx.mjs scripts/build-all.mts sourcePerformance: PASS,236.4s. This is native runtime validation, not full release/package validation.Not tested: successful native Gateway RPC/wake, heartbeat changes, session/channel delivery, live agent/provider behavior, Windows/macOS, full repository suite, full release packaging or upstream CI. Native proof covers the changed local refusal paths; it does not claim that a Gateway accepted an event.
Exact-head proof receipt
Captured native before/after readback
The driver captures real built-CLI subprocess output and replaces only its temporary state/checkout prefixes.
{ "before": { "status": "PASS", "phase": "red", "head": "48b92409887ac4e7b8c67883918a3fee2d9250c9", "buildCommit": "48b92409887ac4e7b8c67883918a3fee2d9250c9", "node": "v24.22.1", "capturedAt": "2026-11-15T15:48:19.293Z", "driverSha256": "6f3b7165ce803e4ec83b8ffa34b57ebe156aa9ece8608e55e55714eea5131cfa", "observations": [ { "args": [ "system", "event", "--text", "probe", "--mode", "later", "--json" ], "exit": 1, "stdout": "{\n \"ok\": false,\n \"error\": {\n \"type\": \"cli_error\",\n \"message\": \"--mode must be now or next-heartbeat\"\n }\n}\n", "stderr": "", "hasActionableStderr": false }, { "args": [ "system", "event", "--text", "probe", "--mode", "later" ], "exit": 1, "stdout": "", "stderr": "--mode must be now or next-heartbeat\n" }, { "args": [ "system", "event", "--text", " ", "--json" ], "exit": 1, "stdout": "{\n \"ok\": false,\n \"error\": {\n \"type\": \"cli_error\",\n \"message\": \"--text is required. Example: openclaw system event --text \\\"deploy finished\\\".\"\n }\n}\n", "stderr": "", "hasActionableStderr": false }, { "args": [ "system", "event", "--text", " " ], "exit": 1, "stdout": "", "stderr": "--text is required. Example: openclaw system event --text \"deploy finished\".\n" }, { "args": [ "system", "event", "--help" ], "exit": 0, "stdout": "\nOpenClaw 2026.11.3 (48b9240) — All your chats, one OpenClaw.\n\nUsage: openclaw system event [options]\n\nEnqueue a system event and optionally trigger a heartbeat\n\nOptions:\n --expect-final Wait for final response (agent) (default: false)\n -h, --help Display help for command\n --json Output JSON (default: false)\n --mode <mode> Wake mode (now|next-heartbeat) (default:\n \"next-heartbeat\")\n --password <password> Gateway password (if required)\n --port <port> Local Gateway port\n --session-key <sessionKey> Target a specific session for the event (defaults\n to the agent's main session)\n --text <text> System event text\n --timeout <ms> Timeout in ms (default: \"30000\")\n --token <token> Gateway token (if required)\n --url <url> Gateway WebSocket URL (defaults to\n gateway.remote.url when configured)\n", "stderr": "" } ], "configUnchangedByCommands": true, "limitations": "Isolated Linux built-CLI local argument refusals and help only. No successful wake, Gateway RPC, heartbeat change, session delivery, live agent or cross-OS behavior is claimed." }, "after": { "status": "PASS", "phase": "green", "head": "99379fa9a644f765c48d07df4cae79332dafbc91", "buildCommit": "99379fa9a644f765c48d07df4cae79332dafbc91", "node": "v24.22.1", "capturedAt": "2026-11-15T16:07:23.107Z", "driverSha256": "6f3b7165ce803e4ec83b8ffa34b57ebe156aa9ece8608e55e55714eea5131cfa", "observations": [ { "args": [ "system", "event", "--text", "probe", "--mode", "later", "--json" ], "exit": 1, "stdout": "{\n \"ok\": false,\n \"error\": {\n \"type\": \"cli_error\",\n \"message\": \"--mode must be now or next-heartbeat\"\n }\n}\n", "stderr": "--mode must be now or next-heartbeat\n", "hasActionableStderr": true }, { "args": [ "system", "event", "--text", "probe", "--mode", "later" ], "exit": 1, "stdout": "", "stderr": "--mode must be now or next-heartbeat\n" }, { "args": [ "system", "event", "--text", " ", "--json" ], "exit": 1, "stdout": "{\n \"ok\": false,\n \"error\": {\n \"type\": \"cli_error\",\n \"message\": \"--text is required. Example: openclaw system event --text \\\"deploy finished\\\".\"\n }\n}\n", "stderr": "--text is required. Example: openclaw system event --text \"deploy finished\".\n", "hasActionableStderr": true }, { "args": [ "system", "event", "--text", " " ], "exit": 1, "stdout": "", "stderr": "--text is required. Example: openclaw system event --text \"deploy finished\".\n" }, { "args": [ "system", "event", "--help" ], "exit": 0, "stdout": "\nOpenClaw 2026.11.3 (99379fa) — All your chats, one OpenClaw.\n\nUsage: openclaw system event [options]\n\nEnqueue a system event and optionally trigger a heartbeat\n\nOptions:\n --expect-final Wait for final response (agent) (default: false)\n -h, --help Display help for command\n --json Output JSON (default: false)\n --mode <mode> Wake mode (now|next-heartbeat) (default:\n \"next-heartbeat\")\n --password <password> Gateway password (if required)\n --port <port> Local Gateway port\n --session-key <sessionKey> Target a specific session for the event (defaults\n to the agent's main session)\n --text <text> System event text\n --timeout <ms> Timeout in ms (default: \"30000\")\n --token <token> Gateway token (if required)\n --url <url> Gateway WebSocket URL (defaults to\n gateway.remote.url when configured)\n", "stderr": "" } ], "configUnchangedByCommands": true, "limitations": "Isolated Linux built-CLI local argument refusals and help only. No successful wake, Gateway RPC, heartbeat change, session delivery, live agent or cross-OS behavior is claimed." } }Complete frozen native CLI driver
Save as
community-system-native-proof-20261115.mjs; invoke with an already-built checkout andredorgreen. It verifies the build-info commit against that checkout's HEAD and creates isolated state. The phase changes only the expected observed stderr outcome.Agent assistance
AI-assisted implementation and author audit. The requester waived independent review; the author audit is not represented as independent review. The complete behavior driver and captured output are included above. Raw agent-session logs are omitted because they contain unrelated private context.
Maintainer validation
Validated
bee653f71754b7d97ca9c24bf8077b40ea0e2f39: real CLI stderr restoration, byte-identical JSON/text controls, zero Gateway connections, regression, typecheck and full packed-install receipts. Both validation boundaries remain covered and the test delta is now net zero; the contributor production fix is unchanged.Merge danger: reversible code/test change. Blast radius: stderr presentation of the two local system-event validation failures.