Skip to content

Treat *.example.com in NO_PROXY like .example.com - #1277

Merged
Kludex merged 2 commits into
pydantic:mainfrom
RaphaelFakhri:fix-no-proxy-wildcard-subdomain
Nov 4, 2026
Merged

Kludex merged 2 commits into
pydantic:mainfrom
RaphaelFakhri:fix-no-proxy-wildcard-subdomain

Conversation

@RaphaelFakhri

@RaphaelFakhri RaphaelFakhri commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A NO_PROXY entry such as *.example.com never matches. get_environment_proxies() prepends * to plain hostnames, which turns the entry into all://**.example.com, and URLPattern compiles that to ^(.+\.)?\*\.example\.com$. Requests to www.example.com still go through the proxy.

This change maps a leading *. to the same mount key as a leading . (all://*.example.com), so the entry matches subdomains of example.com. Go's net/http handles *. the same way.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

Fixes #1276

View guided diff

@codspeed

codspeed Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing RaphaelFakhri:fix-no-proxy-wildcard-subdomain (f46b9a4) with main (2fc9158)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread src/httpx2/httpx2/_utils.py Resolved
@RaphaelFakhri

Copy link
Copy Markdown
Contributor Author

Added the slash guard to the *. branch, plus a test that *.github.com/path is ignored.

@Kludex
Kludex merged commit 0f49350 into pydantic:main Nov 4, 2026
15 checks passed
@Kludex Kludex mentioned this pull request Nov 16, 2026
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.

*.example.com in NO_PROXY never bypasses the proxy

2 participants