fix(env): clean up overrides when setup fails - #342
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 5:04 AM ET / 09:04 UTC. ClawSweeper reviewWhat this changesThe PR cleans up temporary server environment values when setup fails, adds regression coverage, and documents the behavior. Merge readiness✅ Ready for maintainer review This remains a necessary, well-supported fix: main and v0.13.8 still expose the reported failure. No actionable patch defects were found. Priority: P2 Review scores
Verification
How this fits togetherMCPorter applies server-specific environment values while connecting MCP transports. Those values can reach spawned server processes, so cleanup determines what later connections inherit. flowchart TD
A[Server configuration] --> B[Apply temporary environment]
B -->|Valid values| C[Connect MCP transport]
B -->|Invalid value| D[Remove applied keys]
C -->|Success or failure| D
D --> E[Return result or error]
E --> F[Later MCP connections]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Failed connection setup should leave no temporary environment values for later servers while preserving existing value precedence. Do we have a high-confidence way to reproduce the issue? Yes. Main visibly leaves an earlier temporary value behind when a later override throws; supplied public-runtime before-and-after results confirm that path. This read-only review did not execute it. Is this the best way to solve the issue? Yes. Extending the existing try/finally to include setup is the narrowest correction and preserves validation order, inherited-value precedence, and callback cleanup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ab0c27f03fd7. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Strengthen the partial-setup regression assertions, document cleanup ownership, and credit the original contributor. Co-authored-by: JUSHUANGHUI LI <oodadoudou@gmail.com>
Preserve the reviewed environment fix and both Unreleased entries while incorporating openclaw#343 and openclaw#341. Co-authored-by: JUSHUANGHUI LI <oodadoudou@gmail.com>
When a server's later environment value fails validation or resolution,
withEnvOverridespreviously threw before entering its cleanup block. Earlier temporary writes remained in the parent process and could be inherited by the next MCP subprocess even though the failed connection callback never ran.Move the setup loop inside the existing
try/finally, retaining inherited-value precedence and cleanup ownership. Thanks @oodadoudou (JUSHUANGHUI LI) for the fix. The maintainer follow-up adds changelog credit, documents failed-setup cleanup, and checks that inherited values remain unchanged and invalid values are never applied.On Node 24.20.0 / pnpm 10.34.5,
pnpm checkandpnpm testpass: 1,793 tests passed, 26 skipped. Independent proof uses built publiccreateRuntime()on the original baselineab0c27f03fd7d27aa5b48774ac749a4548836234and the candidate. For both unsupported${env:VAR}and missing$env:VARforms, a failed connection is followed in the same process by a real local stdio MCP server. Initialization, tools/list, and tools/call complete successfully.Base leaves the synthetic temporary value in the parent and the next MCP server; candidate leaves it absent in both. An inherited synthetic value stays unchanged in both revisions. The driver closes every runtime in
finally. No transport/helper mocks, private configuration, or credentials are used.Full-candidate isolated Codex review (original patch plus maintainer changes) found no actionable P0–P2 issues. The contributor's original commit is preserved; the maintainer follow-up carries a co-author trailer.
The existing contributor branch was reconciled with main after #343 and #341 by a normal merge commit. Both independent changelog entries and contributor history were preserved. Frozen install/build, all 19 focused environment/OAuth regressions, and the built public-runtime subprocess proof pass again on the combined candidate. Full combined P0–P2 reviews before the integration commit and landing found no actionable issues.
Final head:
8bc87249aa482e0860d7d04120d8fe4d18788838; base:30880f8aa17ae4c247314e2a1a0ac7b18c190cf9. CI passed on Ubuntu, macOS 15, and Windows, including the full suites. Fork workflow approval was granted after reviewing the exact candidate and unchanged workflow. No CI test failures or reruns were needed.