Skip to content

Fix no_proxy IPv6 CIDR crash in get_environment_proxies#967

Open
mbeijen wants to merge 1 commit into
pydantic:mainfrom
mbeijen:fix-ipv6-no-proxy-cidr
Open

Fix no_proxy IPv6 CIDR crash in get_environment_proxies#967
mbeijen wants to merge 1 commit into
pydantic:mainfrom
mbeijen:fix-ipv6-no-proxy-cidr

Conversation

@mbeijen
Copy link
Copy Markdown
Contributor

@mbeijen mbeijen commented May 19, 2026

no_proxy=fe80::/10 (or any IPv6 CIDR) crashed Client() construction because get_environment_proxies() bracketed the whole string including the CIDR suffix, producing the invalid URL pattern "all://[fe80::/10]". Bracket only the address portion and append the suffix outside the brackets.

Closes #899.

Upstream: https://github.com/encode/httpx/issues/3574

no_proxy=fe80::/10 (or any IPv6 CIDR) crashed Client() construction because
get_environment_proxies() bracketed the whole string including the CIDR
suffix, producing the invalid URL pattern "all://[fe80::/10]". Bracket only
the address portion and append the suffix outside the brackets.

Closes pydantic#899.

Upstream: https://github.com/encode/httpx/issues/3574
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 19, 2026

Merging this PR will not alter performance

✅ 7 untouched benchmarks


Comparing mbeijen:fix-ipv6-no-proxy-cidr (2fb3053) with main (c1d3d95)

Open in CodSpeed

mbeijen added a commit to mbeijen/httpx2 that referenced this pull request May 19, 2026
Setting no_proxy patterns matched by hostname string comparison.
So 192.168.0.1 would not match all://192.168.0.0/16.

Add IPNetPattern, backed by ipaddress.ip_network, and a build_url_pattern()
factory that returns IPNetPattern for all:// patterns containing a slash and
WildcardURLPattern otherwise. Introduce a Pattern protocol so Client and
AsyncClient can hold either kind in their _mounts dict.

URLPattern is kept as a backward-compatible alias for WildcardURLPattern.

Together with pydantic#967 will close
 - pydantic#829
 - pydantic#899

Ported from encode/httpx#3741.

Co-Authored-By: Ondrej Filip <ondrej.filip@firma.seznam.cz>
Co-Authored-By: Bill Peck <bpeck@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error parsing some ipv6

1 participant