Skip to content

fix(gateway): handle exec approvals persistence errors#79861

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
martins-oss:rex/approval-hardening-828
Jun 28, 2026
Merged

fix(gateway): handle exec approvals persistence errors#79861
vincentkoc merged 1 commit into
openclaw:mainfrom
martins-oss:rex/approval-hardening-828

Conversation

@martins-oss

@martins-oss martins-oss commented May 9, 2026

Copy link
Copy Markdown
Contributor

What

Wrap local exec.approvals.get and exec.approvals.set gateway 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 explicit UNAVAILABLE response instead.

How

  • Converts local get/set handlers to async handlers using existing respondUnavailableOnThrow.
  • Preserves existing validation/base-hash behavior.
  • Adds focused regression coverage for read/ensure and persist failures.

Real behavior proof

Behavior or issue addressed: Local gateway exec.approvals.get returns a structured RPC UNAVAILABLE response 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-828 on Linux (iris-gateway), Node v22.22.0, running the patched gateway handler directly with node --import tsx. Filesystem failure reproduced with a temp OPENCLAW_HOME whose .openclaw state 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/.openclaw to a separate temp directory; imported src/gateway/server-methods/exec-approvals.ts from this patched checkout; called execApprovalsHandlers['exec.approvals.get'] with a real handler request object and captured respond.

Evidence after fix: Console output from the patched checkout:

$ node --import tsx .tmp-proof-exec-approvals-get.mjs
{
  "ok": false,
  "code": "UNAVAILABLE",
  "message": "Error: Refusing to traverse symlink in exec approvals path must not traverse symlinked directory: /tmp/openclaw-approval-proof-zx6W3i/.openc"
}

Observed result after fix: The patched local handler caught the real filesystem safety exception and returned { ok: false, code: "UNAVAILABLE" } through respond, which is the intended structured RPC failure mode. May 2026 live gateway log review also confirmed approval RPC activity (exec.approval.list succeeded 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.set live 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.ts
  • pnpm format:check src/gateway/server-methods/exec-approvals.ts src/gateway/server-methods/exec-approvals.test.ts
  • pnpm lint:core
  • pnpm tsgo:core:test

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 9, 2026
@clawsweeper

clawsweeper Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 23, 2026, 9:28 PM ET / 01:28 UTC.

Summary
The PR wraps local exec.approvals.get and exec.approvals.set handlers with structured unavailable-error handling and adds focused regression tests for read/setup and save failures.

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
Persistent data-model change detected: serialized state: src/gateway/server-methods/exec-approvals.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Refresh the branch against current main and rerun required checks, including Dependency Guard.

Risk before merge

  • [P1] Required checks are stale against current main: a member comment specifically says the branch needs updating before the new Dependency Guard check can pass.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow local-handler UNAVAILABLE mapping and regression tests after maintainer review and fresh current-main required checks pass, without changing the exec approvals storage model or protocol shape.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is indicated; maintainers need to refresh the branch/checks and review the ready focused gateway bug-fix patch.

Security
Cleared: The diff only changes gateway handler error mapping and tests; it adds no dependencies, workflows, permissions, package metadata, downloads, or secret-handling expansion.

Review details

Best possible solution:

Land the narrow local-handler UNAVAILABLE mapping and regression tests after maintainer review and fresh current-main required checks pass, without changing the exec approvals storage model or protocol shape.

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 respondUnavailableOnThrow helper at the local handler boundary is the narrowest maintainable fix; a global dispatcher catch would over-map unrelated handler bugs, and storage-level catches would hide intentional safety failures.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 63874fa0d119.

Label changes

Label justifications:

  • P2: This is a normal-priority gateway error-handling bug fix with limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies terminal proof from a patched Linux checkout invoking the real local handler path against a filesystem safety failure and observing a structured UNAVAILABLE response.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies terminal proof from a patched Linux checkout invoking the real local handler path against a filesystem safety failure and observing a structured UNAVAILABLE response.
Evidence reviewed

PR surface:

Source +4, Tests +82. Total +86 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 28 24 +4
Tests 1 82 0 +82
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 110 24 +86

What I checked:

Likely related people:

  • steipete: GitHub history shows steipete introduced exec approvals tooling and later refactored the gateway validation/base-hash and node invoke error-handling paths this PR extends. (role: feature-history owner; confidence: high; commits: 3686bde783fd, b743e652c0a0, 73a97ee25539; files: src/gateway/server-methods/exec-approvals.ts, src/infra/exec-approvals.ts, src/gateway/server-methods/nodes.helpers.ts)
  • vincentkoc: Recent commits touched exec approval state-dir behavior and shared exec approvals node invoke handling near the gateway/server-methods and storage paths reviewed here. (role: recent area contributor; confidence: medium; commits: c6232347dcb2, adad27d7448e, 4d6593642e5a; files: src/gateway/server-methods/exec-approvals.ts, src/infra/exec-approvals.ts)
  • Alex-Alaniz: Recent merged persistence-hardening work covered exec approval write fallback failures adjacent to the storage errors this PR maps into structured gateway responses. (role: adjacent persistence-hardening contributor; confidence: medium; commits: b971ebaaab65; files: src/infra/exec-approvals.ts, src/infra/exec-approvals-store.test.ts)
  • jesse-merhi: Recent exec authorization planner work touched exec approval persistence, allow-always behavior, and focused approval coverage, making this person relevant for broader exec approval review context. (role: adjacent exec approvals contributor; confidence: medium; commits: c9707ab635b9; files: src/infra/exec-approvals.ts, src/gateway/server-methods/exec-approval.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
@RomneyDa

Copy link
Copy Markdown
Member

Heads up: this PR needs to be updated against current main before the new required Dependency Guard check can pass.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jun 14, 2026
@vincentkoc
vincentkoc force-pushed the rex/approval-hardening-828 branch from 1960b3a to 9cdcb9c Compare June 28, 2026 20:27
@vincentkoc
vincentkoc merged commit 904c871 into openclaw:main Jun 28, 2026
94 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 29, 2026
QiuYuang pushed a commit to QiuYuang/openclaw that referenced this pull request Jul 1, 2026
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 1, 2026
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants