mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
fix: use bare ::1 in NO_PROXY to avoid crashing Python httpx (#340)
* fix: use bare ::1 in NO_PROXY to avoid crashing Python httpx Bracketed [::1] is URL authority syntax, not valid NO_PROXY syntax. Python's urllib/httpx parses bracketed entries as a URL and crashes with 'Invalid port: :1]'. Use the bare IPv6 loopback ::1 instead, which both Node and Python accept. Fixes #339 https://claude.ai/code/session_01NnkUKCn82Dc83VandSsgim * chore: condense NO_PROXY comment https://claude.ai/code/session_01NnkUKCn82Dc83VandSsgim * docs: note Node IPv6 literal NO_PROXY trade-off https://claude.ai/code/session_01NnkUKCn82Dc83VandSsgim --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,22 @@ func TestSetupEnvForProxyConfiguresYarn(t *testing.T) {
|
||||
"yarn ignores NODE_EXTRA_CA_CERTS; YARN_HTTPS_CA_FILE_PATH is required to trust the MITM CA")
|
||||
}
|
||||
|
||||
// TestSetupEnvForProxyNoProxyIPv6 proves the fix for #339: the IPv6 loopback in
|
||||
// NO_PROXY must be bare (::1), not bracketed ([::1]). Brackets are URL syntax,
|
||||
// not NO_PROXY syntax, and Python's urllib/httpx crashes parsing them with
|
||||
// "Invalid port: ':1]'".
|
||||
func TestSetupEnvForProxyNoProxyIPv6(t *testing.T) {
|
||||
f := &proxyFlow{}
|
||||
env := envToMap(f.setupEnvForProxy("127.0.0.1:54321", "/tmp/pmg-ca-cert.pem"))
|
||||
|
||||
for _, key := range []string{"NO_PROXY", "no_proxy"} {
|
||||
assert.Equal(t, "localhost,127.0.0.1,::1", env[key],
|
||||
"%s must use bare ::1; bracketed [::1] is invalid NO_PROXY syntax and crashes httpx", key)
|
||||
assert.NotContains(t, env[key], "[::1]",
|
||||
"%s must not contain bracketed IPv6 loopback", key)
|
||||
}
|
||||
}
|
||||
|
||||
// TestCIEnvOverride proves the fix for #335: pmg forces CI=true for
|
||||
// non-interactive runs but must not clobber a CI value the user set
|
||||
// explicitly (e.g. CI=false on a build server).
|
||||
|
||||
Reference in New Issue
Block a user