fix: fix stale proxy env restoration after shell snapshots (#17271)

## Summary

This fixes a stale-environment path in shell snapshot restoration. A
sandboxed command can source a shell snapshot that was captured while an
older proxy process was running. If that proxy has died and come back on
a different port, the snapshot can otherwise put old proxy values back
into the command environment, which is how tools like `pip` end up
talking to a dead proxy.

The wrapper now captures the live process environment before sourcing
the snapshot and then restores or clears every proxy env var from the
proxy crate's canonical list. That makes proxy state after shell
snapshot restoration match the current command environment, rather than
whatever proxy values happened to be present in the snapshot. On macOS,
the Codex-generated `GIT_SSH_COMMAND` is refreshed when the SOCKS
listener changes, while custom SSH wrappers are still left alone.

---------

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
viyatb-oai
2026-04-20 16:39:17 -07:00
committed by GitHub
parent 9ef1cab6f7
commit 33fa952426
5 changed files with 537 additions and 17 deletions

View File

@@ -177,6 +177,11 @@ fn run_realtime_conversation_test_in_subprocess(
.arg("--exact")
.arg(test_name)
.env(REALTIME_CONVERSATION_TEST_SUBPROCESS_ENV_VAR, "1");
// The child talks to a loopback websocket server; parent proxy settings can
// route that connection away from the test server in Bazel environments.
for &key in codex_network_proxy::PROXY_ENV_KEYS {
command.env_remove(key);
}
match openai_api_key {
Some(openai_api_key) => {
command.env(OPENAI_API_KEY_ENV_VAR, openai_api_key);