Repository navigation
test: make HTTP mocks independent of environment proxy routing - #637
Merged
Mehak Bindra (MehakBindra) merged 2 commits intoOct 16, 2026
Merged
Conversation
Construct mocked HTTPX clients with explicit transports and preserve settings and event hooks for clones. Add proxy-environment regressions without changing production proxy behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 75921e14-a409-4a9a-bb03-08659dc023de (cherry picked from commit 24ccd41) Copilot-Session: 70488242-a4f5-4f62-86f7-91d9335545c2
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking issues in these test/documentation-only changes; complete execution validation remains with CI.
No open issues 🎉
What changed in this PR
Makes API/common HTTP test mocks independent of environment proxy routing, without changing production networking or dependencies.
Changes:
- Inject mock transports when constructing HTTP clients.
- Preserve clone settings, event hooks, and shared-client behavior.
- Add proxy regression coverage and document the mocking pattern.
| File | Description |
|---|---|
| packages/common/tests/test_client.py | Updates mock setup and adds proxy coverage. |
| packages/api/tests/unit/test_fixtures.py | Tests proxy isolation and cloned mock clients. |
| packages/api/tests/unit/test_conversation_client.py | Injects mock transports at construction. |
| packages/api/tests/unit/test_base_client.py | Updates the mock client factory. |
| packages/api/tests/conftest.py | Updates shared fixtures and clone handling. |
| CONTRIBUTING.md | Documents proxy-safe HTTP mocking. |
Review effort: Balanced
Lily Du (lilyydu)
approved these changes
Oct 16, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70488242-a4f5-4f62-86f7-91d9335545c2
Lily Du (lilyydu)
approved these changes
Oct 16, 2026
Mehak Bindra (MehakBindra)
deleted the
mehakbindra-http-mock-proxy-fix
branch
October 16, 2026 22:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cherry-pick 24ccd41 onto main with
-xprovenance, with the CONTRIBUTING.md addition subsequently removed. This PR contains only the test fix in five files; it does not include release-only ancestry, the 2.1.1 version bump, dependency changes, or production proxy/TLS changes.Construct mocked
httpx.AsyncClientinstances with explicitMockTransportbefore injecting them into SDKClientvia_http, rather than replacing_transportafter HTTPX has configured proxy mounts. Preserve clone settings, event hooks, andshare_httpbehavior. Add proxy-environment regression coverage.Context
ADO publish run 20467 failed 117 tests because real HTTP requests bypassed mocks. HTTPX 0.28.1/HTTP Core 1.0.9 and the affected test setup/YAML were unchanged from successful run 17012. The image and 1ESNetworkIsolation task changed (29.0.0 / 1.0.175 to 41.0.0 / 1.0.185), alongside Python and AnyIO versions; the exact trigger of proxy routing remains unproven.
HTTPX confirms the failure mechanism. Its proxy-discovery code reads proxy settings through Python’s
getproxies(), including the Windows registry, not just environment variables. Its client code checks proxy mounts before the default transport—so replacing_transportafterward can leave proxies active.User-directed sequence: main first, then backport the merged commit to release/v2.1. This supersedes the proposed release-first fix in #636; closing that PR and handling the later backport are left to the coordinating session. Nothing is being merged or published here.
Validation
HTTP_PROXY,HTTPS_PROXY, andALL_PROXYset tohttp://127.0.0.1:1andNO_PROXYempty. Imports were confirmed to resolve to this worktree. The wheel-build test was excluded only from this local forced-proxy run, not changed or skipped in CI.HandshakeFailure.