Repository navigation
Keep CLI test children off the host's Go env - #2063
Conversation
A developer or runner that exports GOWORK, GOFLAGS=-modfile=..., GOMODCACHE or GOPATH (or sets them with `go env -w`) leaks them into every socket-patch and `go` child the CLI tests spawn. With GOWORK=<file> exported, every `go mod download` in the Go suites' staging fails; with GOFLAGS=-modfile=... Go vendor refuses to write its replace. e2e_golang_build failed 21/21 and e2e_vendor_golang_build 11/13 that way on a clean checkout. Add hermetic::Extra::Go (remove GOFLAGS, GOWORK, GOPATH, GOMODCACHE; set GOENV=off) and apply it to CRAWLER_EXTRAS, to every child of common::run_bin_with_env, and to the go/socket-patch spawn helpers of e2e_golang_build, e2e_golang_hosted_build and e2e_vendor_golang_build. Tests that need a value still set it after the scrub. A spawn_env_hygiene self-test pins the scrub. Part of #1981 (items 1-2). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeR7CFpkqZDdd9hfYmM
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview Go joins Reviewed by Cursor Bugbot for commit 5b42c27. Configure here. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 5b42c27. Configure here.
|
Ready for review (burn-down agent).
Generated by Claude Code |
Final review briefWhat it does. Test-only change. It adds a Go scrub ( Risk: low. Only files under Look here
Verified
Changes I made: none. Open questions: none blocking. Nit: the doc comment changed at Auto-merge (squash) is armed, so approving sends this straight to the merge queue. Generated by Claude Code |
Problem
CI was healthy on this run. The merge queue was empty, and all 28 merge_group runs since 11-12 18:56 UTC passed. Main's latest push run (43324491043) is green. Nothing was queued or in progress, and no PR run in the last 3 days needed a re-run because of a flake. Last night's Windows nightly failure (
scan_hosted_paths_run_once_per_project_directory) was already fixed by #2061. So this run takes a priority-4 robustness target, in the same class as #2054, #2055, #2056 and #2057: tests that pass only because CI's environment is clean.#2057 kept the core unit tests off the host's Go env. The CLI integration tests still pass the parent's
GOWORK,GOFLAGS,GOMODCACHE,GOPATHandgo env -wfile on to everysocket-patchandgochild they spawn (#1981, items 1–2). Onorigin/main(de81f1b), withGOFLAGS=-modfile=/nonexistent/alt.mod GOWORK=/nonexistent/go.workexported:e2e_golang_buildgo mod downloadinstagefails on the ambientGOWORK)e2e_vendor_golang_buildvendorrefuses: "GOFLAGS sets -modfile=…, which go refuses in workspace mode")e2e_golangspawn_env_hygieneWith a clean env, every suite this PR touches passes before and after:
e2e_golang,e2e_golang_build,e2e_golang_hosted_build,e2e_vendor_golang_build,e2e_hosted_production,e2e_vendored_productionandspawn_env_hygiene.Root cause
hermetic.rshas a scrub (Extra) for every other ecosystem whose config the crawler reads from the environment (venv, Bundler, Composer, PDM, Poetry), but none for Go. Thegohelpers in the Go suites set only some keys, and pinGOWORKin none of them.Fix
hermetic::Extra::Go. It removesGOFLAGS,GOWORK,GOPATHandGOMODCACHE, then setsGOENV=offso the same keys can't come back from thego env -wfile.CRAWLER_EXTRAS, which covers the vex e2e harness, the hosted and vendored production suites, and the gem suites.common::run_bin_with_env, right afterjvm_env::isolate_cli, so it reaches everyrun/run_with_envchild.go()/run_socketspawn helpers ofe2e_golang_build,e2e_golang_hosted_buildande2e_vendor_golang_build, beforecache_env::isolate(scrub first, as the ordering rule inhermetic.rssays).GOMODCACHE,GOFLAGS,GOENVpins). The existing-modfile/GOWORKtests set theirs explicitly and still pass.crawler_inputs_sweep_go_module_cache_and_flags.On CI this changes nothing: no workflow exports these variables and runners have no
go env -wfile. It protects developer machines, and CI if a runner image ever starts setting them.Not in this PR (left for #1981)
e2e_golang_hosted_build(2) ande2e_golang_workspace_build(5) still fail with the hostile env. They call core discovery in-process (discover_patched_refs,go_workspace::load), which reads the test process's own env, so a spawn scrub can't reach them.std::env::set_varhostile-value guards (GOTOOLCHAINetc.) are intentional RED guards and stay as they are.e2e_hosted_production's golang/deno legs that can't fail (hermetic test children inherit GOFLAGS, GOENV, GOWORK, GOPATH and GOMODCACHE, which the go crawler and apply read; two hosted-production Go/Deno tests can't fail #1981 item 4).Where tests run
No test was removed or moved. Only spawn env changed.
Validation
rustfmt --checkon the touched files: clean.cargo clippy -p socket-patch-cli --all-targets -- -D warningsfails locally only on errors that already exist on main (prebuilt_common/mod.rs,repair.rs,common/mod.rs:27duplicate-module lint). None are in lines this PR changes. CI's clippy job doesn't use--all-targets.Generated by Claude Code
Generated by Claude Code