fix(gateway): handle exec approvals persistence errors#79861
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 23, 2026, 9:28 PM ET / 01:28 UTC. Summary PR surface: Source +4, Tests +82. Total +86 across 2 files. Reproducibility: yes. from source inspection: current main invokes local approval persistence helpers directly, and those helpers can throw on real filesystem read/write safety failures. I did not execute a failing current-main repro because this cleanup review is read-only. Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrow local-handler Do we have a high-confidence way to reproduce the issue? Yes from source inspection: current main invokes local approval persistence helpers directly, and those helpers can throw on real filesystem read/write safety failures. I did not execute a failing current-main repro because this cleanup review is read-only. Is this the best way to solve the issue? Yes. Reusing the existing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 63874fa0d119. Label changesLabel justifications:
Evidence reviewedPR surface: Source +4, Tests +82. Total +86 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Heads up: this PR needs to be updated against current |
1960b3a to
9cdcb9c
Compare
What
Wrap local
exec.approvals.getandexec.approvals.setgateway handlers in structured unavailable-error handling.Why
May gateway logs showed approval RPC traffic (
exec.approval.list) but local approvals persistence paths could still throw through the request handler if state read/write failed, producing only generic gateway handler failures. This hardens the local path to match node approval handlers and returns an explicitUNAVAILABLEresponse instead.How
respondUnavailableOnThrow.Real behavior proof
Behavior or issue addressed: Local gateway
exec.approvals.getreturns a structured RPCUNAVAILABLEresponse when approval state setup/read fails, instead of letting the filesystem exception bubble to the generic gateway request-handler failure path.Real environment tested: OpenClaw checkout
rex/approval-hardening-828on Linux (iris-gateway), Node v22.22.0, running the patched gateway handler directly withnode --import tsx. Filesystem failure reproduced with a tempOPENCLAW_HOMEwhose.openclawstate dir is a symlink to another temp dir, triggering the real exec-approvals path safety guard.Exact steps or command run after this patch: Created temp
OPENCLAW_HOME; symlinked$OPENCLAW_HOME/.openclawto a separate temp directory; importedsrc/gateway/server-methods/exec-approvals.tsfrom this patched checkout; calledexecApprovalsHandlers['exec.approvals.get']with a real handler request object and capturedrespond.Evidence after fix: Console output from the patched checkout:
Observed result after fix: The patched local handler caught the real filesystem safety exception and returned
{ ok: false, code: "UNAVAILABLE" }throughrespond, which is the intended structured RPC failure mode. May 2026 live gateway log review also confirmed approval RPC activity (exec.approval.listsucceeded on May 9 at 07:18 and 07:41 ET).What was not tested: No live gateway restart/deploy was performed, and no production approval state was mutated.
exec.approvals.setlive failure was not forced against the running gateway; it is covered by focused regression tests plus the same shared wrapper path.Testing
node scripts/test-projects.mjs --maxWorkers=1 src/gateway/server-methods/exec-approvals.test.ts src/infra/exec-approvals-store.test.tspnpm format:check src/gateway/server-methods/exec-approvals.ts src/gateway/server-methods/exec-approvals.test.tspnpm lint:corepnpm tsgo:core:test