fix(macos): supply proxy env only at exec, so Codex keeps its identity token #442
Reference in New Issue
Block a user
Delete Branch "fix/duplicate-proxy-env-drops-identity-token"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #441.
Problem
container exec --envappends to the run-time environment on Apple Container rather than replacing it. The launch path baked a token-less*_PROXYatcontainer runand relied on the exec-time token-bearing value superseding it, so the agent'senvironends up with twoHTTPS_PROXYentries, token-less first.Which one a runtime reads is luck: Node takes the last (Claude worked), Rust's
std::env::vartakes the first (Codex proxied with no identity token)./resolverequires a matching(source_ip, identity_token)pair and fail-closes, so every request from a Codex bottle was denied while its registry row was perfectly correct.Confirmed in
/proc/<pid>/environon live containers: Claude and Codex agents both carry the duplicate, in the same order.Change
Drop the run-time proxy vars; the exec-time env is now the single source of
*_PROXY.A token-less proxy URL has no legitimate consumer — the init process is
sleepand everything that egresses arrives via exec. Its one benefit was a tidy 403 for unattributed callers, which is not worth silently dropping attribution for; and a process egressing before the exec-time env still fails closed, since the agent network is host-only and the gateway is the only route off it.Also corrects the two comments asserting the false "exec
--envwins" invariant (launch.py:269,bottle.py:71-73) — that assumption is why this survived review.Tests
Replaces
test_run_time_proxy_carries_no_identity_token(which encoded the buggy behaviour) withtest_run_time_env_sets_no_proxy_vars_at_all, plus a narrower check that the run-time env carries no token. 1880 unit tests pass, pyright clean, pylint 9.82.Note
Independent of #440 — branched from
main, no overlapping files. Landing either one recreates the shared infra container on the next launch.