Repository navigation
NO_PROXY with bracketed IPv6 literal ([::1]) crashes client construction #3829
Replies: 1 comment
|
This is already tracked in #3221. That issue was opened for the IPv6 CIDR form ( I set So an IPv6 range in a shared The open PR on that issue, #3741, covers the CIDR form and leaves the bracketed one. With its head commit (83d203a) first on The workaround on 0.28.1 is to write IPv6 addresses without brackets and leave IPv6 ranges out. The last two rows show a separate gap. IPv4 ranges don't raise. Only the network address itself goes direct, so If switching is an option, the pydantic/httpx2 fork accepts these forms since 2.14.0 (pydantic/httpx2#1267 for brackets, pydantic/httpx2#1165 for ranges). On httpx2 2.16.2, |
Uh oh!
There was an error while loading. Please reload this page.
Environment
What happened
A
NO_PROXYentry that uses the conventional bracketed form for an IPv6 literal makes client construction raise:The unbracketed form (
NO_PROXY=::1) works, since #2659 / #2674.Root cause
get_environment_proxies()classifies each entry withis_ipv6_hostname(), which passes the value toipaddress.IPv6Address(). That rejects the bracketed form, so[::1]falls through to the domain-pattern branch:URLPatternthen parses:1]as a port and raisesInvalidURL.Fix
Strip the surrounding brackets before classifying the entry, so
[::1]is treated exactly like::1and producesall://[::1].I have the change plus a regression test on a fork branch. PR creation on this repository appears to be restricted to collaborators, so I could not open one:
https://github.com/dem0ns/httpx/tree/fix-no-proxy-bracketed-ipv6
Happy to open a PR if outside contributions are enabled.
All reactions