Repository navigation
fix(gateway): omit JavaScript class names from proven RPC failures - #124563
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 8:31 AM ET / 12:31 UTC. ClawSweeper reviewWhat this changesThis PR adds a Gateway-local ErrorShape constructor and uses it at eight proven RPC failure producers so clients receive redacted messages without JavaScript error class names while retaining structured codes. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessNo blocking findings: current main still emits diagnostic error formatting on the targeted RPC paths, while this PR uses the existing redacting message formatter at the Gateway wire boundary. The protected maintainer label means it should remain open for normal maintainer handling. Priority: P2 Review scores
Verification
How this fits togetherGateway handlers turn filesystem, delivery, session, and agent-run failures into ErrorShape responses consumed by CLI and other RPC clients. The change separates client-facing error text from Gateway diagnostic log rendering. flowchart LR
A[RPC request] --> B[Gateway handler]
B --> C[Filesystem or agent-run failure]
C --> D[Wire error formatter]
D --> E[ErrorShape response]
E --> F[CLI and RPC clients]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +22, Tests +65. Total +87 across 13 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the ErrorShape protocol unchanged and land the Gateway-local redacting bridge after exact-head CI completes successfully. Do we have a high-confidence way to reproduce the issue? Yes, with high confidence: current main directly stringifies or log-formats the implicated errors, and the PR body includes an isolated Gateway CLI before/after transcript for the fs.listDir path. Is this the best way to solve the issue? Yes. A Gateway-owned bridge is the narrowest maintainable location because the protocol-level ErrorShape constructor cannot import Gateway redaction policy, while the existing formatter already defines the desired message and code behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 66db70133b2c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…penclaw#124563) * fix(gateway): keep diagnostic formatting out of wire errors * test(gateway): cover strict delivery wire errors * test(gateway): complete strict delivery request fixture
What Problem This Solves
Fixes an issue where operators could receive JavaScript error class names in Gateway RPC failures when a handler passed a diagnostic formatter or raw
String(error)intoErrorShape.message.The concrete live reproduction was
fs.listDiron a missing workspace descendant. The CLI renderedGateway call failed: Error: ENOENT: ..., even thoughErrorShape.messageis the user-facing wire contract shared by the CLI, Control UI, plugins, and ACP.Why This Change Was Made
Adds one Gateway-owned
errorShapeFromErrorconstructor that uses the canonical redactingformatErrorMessageWithCoderenderer, then adopts it at eight producers with proven handler/client reachability:src/gateway/server-methods/fs.ts:119fs.readdir;ENOENTpreviously becameError: ENOENT.... Live CLI proof is below.src/gateway/agent-turn/agent-delivery-phase.ts:142resolveMessageChannelSelection, whose ordinaryErrorpreviously leakedError:.src/gateway/agent-turn/agent-delivery-phase.ts:153Error; the new owner-boundary test proves the message omits the class and retainsINVALID_TARGET.src/gateway/agent-turn/agent-delivery-phase.ts:177Errorfamily; an existing handler test reproducedError: Delivering to Telegram requires target.src/gateway/agent-turn/agent-turn-service.ts:414Error: Session ... was deleted...; the existing handler test already asserted the old prefix exactly.src/gateway/agent-turn/agent-session-persist.ts:373src/gateway/agent-turn/agent-session-persist.ts:431src/gateway/agent-turn/agent-run-admission-phase.ts:353This deliberately does not change
formatForLog; diagnostic logs keep error names and diagnostic formatting.Inventory and guard decision
The task's 55-site grep count was incomplete on current
main: a balanced AST inventory found 67 message expressions across 34 files because 12 multiline calls were missed. Of those, 60 can receive anError, six are already behavior-neutral because theirErrorbranch uses.message, and one stringifies a schema-validated identifier rather than an error.This PR changes 8 proven sites and deliberately leaves 59:
secrets.resolvetarget identifier coercion.I did not add the proposed AST guard. Making it pass now would require either 52 additional untested behavior changes or roughly 59 allow comments that normalize known debt. The single canonical constructor makes the correct new path obvious without institutionalizing that baseline; a future guard is worthwhile once the remaining handlers have focused wire tests.
User Impact
For the repaired RPC paths, clients now render the actionable operator message and structured error code without a JavaScript class prefix. Structured primary and cause-chain codes still survive, and sensitive text still goes through the canonical redactor.
No protocol shape,
ErrorShape, outer Gateway error codes, or diagnostic log formatting changed. No changelog entry was added, per task instructions.Production LOC: +33/-22 (net +11). Tests/test support: +89/-13 (net +76).
Evidence
Live isolated scratch Gateway on port 19789 with channels skipped:
The JSON response retained outer
code: INVALID_REQUEST; only the wire message changed, and it now retains the filesystem's structuredENOENT.Validation:
String(Error)producer restored temporarily; it failed withError: Reserved target...and missingINVALID_TARGET, then passed with the canonical helper.node scripts/run-vitest.mjs src/gateway/server-methods/fs.test.ts src/gateway/server-methods/agent.test.ts src/gateway/server.agent.gateway-server-agent-a.test.ts src/gateway/server.agent.gateway-server-agent-b.test.ts— 335 passed.node scripts/run-vitest.mjs src/gateway/agent-turn/agent-delivery-phase.test.ts— 1 passed.pnpm build— passed.node scripts/check-changed.mjs— passed on Blacksmith Testboxtbx_01m057vte4va102gpfnt62v78r; exact successful run: https://github.com/openclaw/openclaw/actions/runs/31946483691.agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output— clean, no accepted/actionable findings. Follow-up test-only reviews were also clean.