Repository navigation
fix(cli): preserve automation error guidance in JSON mode - #142113
Conversation
handleCronCliError now hands JSON-mode failures to the root renderer as an ExpectedCliError with human and machine output, so stderr carries the operator message instead of the "Could not start the CLI." title with the Doctor and debug hints. Human-mode rendering, the JSON envelope, and the exit code are unchanged. Closes openclaw#142110
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. Reviewed September 8, 2026, 9:58 AM ET / 13:58 UTC. ClawSweeper reviewWhat this changesThe automation CLI identifies expected input and Gateway errors so JSON-mode failures show direct operator guidance while preserving debug-gated causes and unexpected-error diagnostics. Merge readiness✅ Ready for maintainer review This PR remains necessary: current main and v2026.9.2 retain the misleading error framing. The earlier cause-gating finding is resolved, GitHub reports the head mergeable, and no actionable correctness defect remains. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s automation CLI validates command input and sends requests to the Gateway scheduler. Its error handler passes failures to the shared CLI renderer, which produces stderr guidance and machine-readable JSON. flowchart TD
A[Automation command input] --> B[Input validation]
B --> C[Gateway request]
B --> D[Automation error handler]
C --> D
D --> E{Expected operator error?}
E -->|Yes| F[Direct guidance and JSON]
E -->|No| G[Runtime failure diagnostics]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +100, Tests +264. Total +364 across 14 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep automation error classification at its producers and use the existing shared renderer without changing output envelopes, exit codes, or unexpected-failure diagnostics. Do we have a high-confidence way to reproduce the issue? Yes: a missing automation queried with Is this the best way to solve the issue? Yes: producer-owned classification reuses the established expected-error renderer and preserves genuine runtime diagnostics, avoiding a blanket conversion of all failures. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a39239faf938. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
The first revision handed the expanded formatErrorMessage result to the root renderer as machineOutput, so a wrapped cron failure such as readCronJobForEdit's "unknown automation id" leaked its "unknown method: cron.get" cause into ordinary JSON. Machine output now goes through formatCliOperatorError, which keeps the renderer's existing gate, so causes stay behind --debug and OPENCLAW_DEBUG. The typed lookup-miss message is unchanged, and human-facing output still carries the full producer message as human mode does. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Thanks, the P2 finding is correct and is fixed in Reproduced it exactly as described: passing the expanded Coverage for both directions, as requested: three new cases in One deliberate difference from the machine-output gate: human-facing stderr still carries the full producer message, because that is what human mode already prints today for the same failure. Making machine-mode stderr match human-mode stderr is the point of the PR. Acceptance criteria, run locally: The red checks on the previous revision were not from the diff: every one failed in @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Mark expected automation failures at their input and domain producers. Keep both machine output streams behind the existing cause policy while preserving original diagnostics for unexpected runtime failures.
Translate duration validation failures at the automation input boundary while preserving the original message and machine-output contract. Merge main and retain upstream explicit-URL credential tests alongside automation lookup and invalid-duration process coverage.
|
Thanks @DasX! Proof: Real CLI/Gateway before-and-after runs preserve JSON and exit status while removing generic crash guidance for expected automation errors. Focused tests passed, independent validation exercised 85 commands across baseline and candidate revisions, and final-head CI is green.
Additional candidate corrections retain nested-cause gating on machine stderr and preserve debug stacks for unexpected runtime errors. Legacy compatibility was checked with a protocol fixture. Controlled missing-module tests cover installation failures. Contributor credit and both upstream credential and automation regression tests were retained. Final CI. |
…42113) Closes openclaw#142110 ## What Problem This Solves Fixes an issue where automation commands in machine-output mode frame ordinary operator errors, such as a missing automation ID or invalid option value, as generic CLI failures with Doctor and debug hints. ## Why This Change Was Made Known automation input and domain failures now use the existing expected-error renderer. Their producers identify them explicitly, so unexpected runtime and programming failures keep their original diagnostics. The shared renderer, JSON envelope, exit status, Gateway requests, and human-mode output remain unchanged. The contributor's first correction restored JSON cause gating. Further verification found that machine stderr still exposed nested causes and that internal runtime failures lost their debug stacks. Both are corrected: machine stdout and stderr use the canonical debug policy, while unexpected exceptions retain their original identity. Malformed cron-run wait durations also use the expected-input path; unrelated shared parsing and protocol-validation failures retain their existing policy. ## User Impact Missing automation IDs and invalid automation options produce direct guidance with exit1 and one canonical JSON document. Nested causes remain hidden in machine mode unless `OPENCLAW_DEBUG` is enabled. Human-mode diagnostics keep their existing full redacted message. Automation commands do not add `--debug` or `--verbose` options. ## Evidence - Real source CLI and Gateway, with fresh isolated automation stores, reproduced generic command-failure stderr on pinned main `c128afa34681`. The corrected integration prints only direct missing-ID guidance, preserving the same JSON and exit status. - The supported older-Gateway compatibility fixture proves wrapped causes remain hidden in both machine streams by default and appear with `OPENCLAW_DEBUG=1`. - Controlled missing-runtime-module cases preserve command/startup framing and debug stacks for genuine installation failures. Modules are restored after each control. - 599 focused tests passed: 521 cron-owner tests, 36 fast/renderer tests, and 42 CLI process tests. Three added regression checks failed on the original contributor implementation before correction. - Independent behavior validation executed 85 commands across the candidate, baseline, and two affected follow-up checks, including typed Gateway rejections, human/JSON output, parse and transport errors, debug policy, disabled automation creation and stored readback. All 66 JSON-producing results contained one document; every subprocess ended without a signal. - Formatting, lint, the normal pre-commit hook, and `git diff --check` passed. Fresh Autoreview found no actionable P0–P2 findings. After a required main merge, all six affected process cases passed with the upstream credential tests retained. Two duration regressions and 22 related run-command tests also passed. Fresh review of the final candidate found no actionable findings. Full CI and typechecking run on GitHub. | Missing automation in JSON mode | Result | | --- | --- | | Before | Generic CLI failure title, Reason, debug, Doctor and Help hints | | After | `Automation not found: missing-job. Run openclaw cron list to see recent automation ids.` | The old-Gateway control is a protocol fixture, not a historical Gateway binary. Source provenance and final physical cleanup are tracked separately from the independent behavioral observations. AI-assisted. Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #142110
What Problem This Solves
Fixes an issue where automation commands in machine-output mode frame ordinary operator errors, such as a missing automation ID or invalid option value, as generic CLI failures with Doctor and debug hints.
Why This Change Was Made
Known automation input and domain failures now use the existing expected-error renderer. Their producers identify them explicitly, so unexpected runtime and programming failures keep their original diagnostics. The shared renderer, JSON envelope, exit status, Gateway requests, and human-mode output remain unchanged.
The contributor's first correction restored JSON cause gating. Further verification found that machine stderr still exposed nested causes and that internal runtime failures lost their debug stacks. Both are corrected: machine stdout and stderr use the canonical debug policy, while unexpected exceptions retain their original identity. Malformed cron-run wait durations also use the expected-input path; unrelated shared parsing and protocol-validation failures retain their existing policy.
User Impact
Missing automation IDs and invalid automation options produce direct guidance with exit1 and one canonical JSON document. Nested causes remain hidden in machine mode unless
OPENCLAW_DEBUGis enabled. Human-mode diagnostics keep their existing full redacted message. Automation commands do not add--debugor--verboseoptions.Evidence
21ad735be2f4. The corrected integration prints only direct missing-ID guidance, preserving the same JSON and exit status.OPENCLAW_DEBUG=1.git diff --checkpassed. Fresh Autoreview found no actionable P0–P2 findings. After a required main merge, all six affected process cases passed with the upstream credential tests retained. Two duration regressions and 22 related run-command tests also passed. Fresh review of the final candidate found no actionable findings. Full CI and typechecking run on GitHub.Automation not found: missing-job. Run openclaw cron list to see recent automation ids.The old-Gateway control is a protocol fixture, not a historical Gateway binary. Source provenance and final physical cleanup are tracked separately from the independent behavioral observations. AI-assisted.