Repository navigation
fix(cli): keep approvals JSON failures parseable - #124585
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 9:15 AM ET / 13:15 UTC. ClawSweeper reviewWhat this changesThe PR makes approvals commands emit one compact JSON error object on stdout in Regression provenancePossible regression — probable (reviewed change; reproduction). No predecessor PR is attributed. Merge readinessKeep open for maintainer merge review. The patch is a coherent CLI-boundary repair with no source-level finding, but the maintainer label requires human handling and this sandbox could not recheck the supplied current-main revision live. Priority: P2 Review scores
Verification
How this fits togetherThe approvals CLI sends operator requests to local state, a Gateway, or a node and renders their results for scripts or terminals. Its action boundary must preserve a machine-readable JSON contract without changing approval transport or policy behavior. flowchart LR
A[Operator approvals command] --> B[CLI action]
B --> C[Local state or Gateway]
C --> D[Success or failure]
D --> E[Shared output decision]
E --> F[JSON stdout]
E --> G[Human stderr]
Decision needed
Why: The patch is protected by the maintainer label, and the review sandbox could not independently refresh current-main state. Before merge
Agent review detailsSecurityNone. PR surfaceSource +3, Tests +16. Total +19 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one bounded output-boundary renderer; no net-neutral alternative preserves all five command actions without restoring duplicated JSON-versus-human failure branches. Do we have a high-confidence way to reproduce the issue? Yes, from source: the base catch paths write only human errors, while the PR-head parser-level test demonstrates the same rejected Gateway call now produces one JSON error and exit 1. The sandbox did not run the test because this review is read-only. Is this the best way to solve the issue? Yes. Centralizing the output-mode decision at the shared action failure boundary is preferable to adding per-command JSON branches or changing Gateway behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8638d50ce663. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Land-ready evidence for
|
|
Merged via squash.
|
What Problem This Solves
Fixes an issue where operators scripting
openclaw approvals ... --jsonwould receive exit 1 with empty machine-readable stdout when pending, resolve, get, set, or allowlist operations failed. The same commands already returned JSON on success, so callers could not reliably parse the advertised output mode.Why This Change Was Made
The approvals CLI now owns failure rendering at each command action boundary. Validation and mutation helpers throw to that boundary, which emits exactly one compact
{ "error": "..." }JSON value in JSON mode or the existing human-readable stderr message otherwise, then exits 1. Error text remains bounded and terminal-sanitized.No flags, authentication behavior, Gateway methods, configuration, or protocol shapes change. This PR is AI-assisted and directly maintainer-reviewed.
Maintainer LOC decision: accept the net +3 production lines. The JSON-versus-human output branch is the required machine-output capability, and centralizing it at one owner boundary removes ten repeated failure-rendering lines; a net-neutral alternative would scatter that policy back across five command actions.
User Impact
Scripts can parse approvals command stdout as one JSON value on both success and failure. Human-mode failures remain on stderr with the same non-zero exit behavior.
Evidence
{error}value on stdout; the human-mode control remains stderr-only.node scripts/run-vitest.mjs src/cli/exec-approvals-cli.test.ts src/cli/exec-approvals-cli.pending-resolve.test.ts— focused owner-boundary tests passed on the reviewed candidate. No rerun was required after the mechanical rebase because all relevant blobs remained identical.{error}stdout value and no duplicated error across streams.pnpm build, changed checks, lint, production/test types, import-cycle checks, built-dist controls, andgit diff --checkpassed during direct review.1599e73baeef5d6547d26f091c1c73e2c5d33c36, includingopenclaw/ci-gate, build artifacts, compact Node shards, lint, production/test types, dependencies, protocol, and boundary checks.8ed5748a84867fbea4eff11f4335952ba95c5d25completed clean with no accepted/actionable findings.1599e73baeef5d6547d26f091c1c73e2c5d33c36has byte-identical changed blobs to the reviewed candidate: productione3a481ba98779895e8804aa4d39d5b7b1d23af97, primary tests96646a695a7237dbd02e836da3b03e81286ce6eb, pending/resolve tests02086858b19fa1100718f96be5ba64fe6b255515.