Skip to content

fix: honor NO_PROXY patterns for environment proxies - #239

Open
hansu650 wants to merge 1 commit into
TencentCloud:masterfrom
hansu650:fix/no-proxy-host-matching
Open

hansu650 wants to merge 1 commit into
TencentCloud:masterfrom
hansu650:fix/no-proxy-host-matching

Conversation

@hansu650

@hansu650 hansu650 commented Nov 28, 2026 •

Copy link
Copy Markdown

Requests still use an environment proxy when NO_PROXY contains a matching domain suffix, wildcard, or IP subnet. For example, HTTPS_PROXY is used for cvm.tencentcloudapi.com despite NO_PROXY=.tencentcloudapi.com. The SDK checks whether the entire host is a substring of the exclusion string, then passes the environment proxy as an explicit Requests proxy. That prevents Requests' own bypass handling from correcting the result.

Use Requests' existing should_bypass_proxies matcher with an HTTP/HTTPS URL, and use the same lowercase-first no_proxy precedence as Requests. An explicitly configured SDK proxy retains its existing precedence.

The new tests exercise the proxies passed to Session.send after normal Requests preparation and environment merging, without making network calls. They cover exact hosts, suffixes, lists, wildcard, IPv4 CIDR, hosts with ports, unmatched hosts, case precedence, and explicit proxies for both HTTP and HTTPS.

Validation on Windows / Python 3.12.16 / Requests 2.34.2:

  • The initial 36-case regression set produced 24 failures before the fix.
  • All 38 final regression cases pass. Together with existing retry, serialization, and deserialization tests: 41 passed, 1 existing skip, 1 existing serialization warning.
  • Existing credential concurrency tests: 4 passed, using dummy credentials with the tests' existing offline mocks and treating unhandled thread exceptions as errors.
  • pycodestyle tests/unit/test_proxy.py, git diff --check, and pip check pass.

Live cloud integration tests, the generated-product import matrix, and other Python/OS combinations were not run.

Prepared with OpenAI Codex assistance; the reproduction was found by inspecting the transport code, not from a production incident.

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.

1 participant