Conversation
Build constructed its http.Transport without a Proxy field, so clients it produced ignored HTTP_PROXY/HTTPS_PROXY/NO_PROXY (a zero-value transport has Proxy: nil, unlike http.DefaultTransport). The auth server's upstream OAuth/DCR client is built via NewHostScopedClientBuilder().Build(), so it bypassed an explicit forward proxy. Set Proxy: http.ProxyFromEnvironment, matching http.DefaultTransport and CloneDefaultTransportWithDialControl. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Antonio Schonmann <antonio.schonmann@trmlabs.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes HttpClientBuilder.Build() so HTTP clients created via pkg/networking honor HTTP_PROXY / HTTPS_PROXY / NO_PROXY, aligning behavior with http.DefaultTransport and the existing vMCP transport path; this unblocks proxy-only upstream OAuth/DCR calls from the embedded auth server.
Changes:
- Set
http.Transport.Proxy = http.ProxyFromEnvironmentinHttpClientBuilder.Build(). - Add a regression test asserting the built transport has a non-nil
Proxyfunction.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/networking/http_client.go | Ensures builder-created transports use proxy env vars by wiring ProxyFromEnvironment. |
| pkg/networking/http_client_test.go | Adds a regression test to prevent dropping the proxy behavior in future refactors. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Hi team, quick pull request for your consideration! 👋 In essence -> this will honor the Thx! |
Addresses review feedback: avoid a panic on structural change and give a clearer failure message. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Antonio Schonmann <antonio.schonmann@trmlabs.com>
|
Thanks for the patch. Do you think it's safe to always pass on the environment proxy variables? |
|
Hey, thanks for checking @jhrozek! Dug into this a bit, and I think always passing is actually a safe choice here. Why:
That's why I'd lean away from a separate |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6670 +/- ##
==========================================
- Coverage 79.31% 79.24% -0.07%
==========================================
Files 800 800
Lines 80936 80937 +1
==========================================
- Hits 64192 64141 -51
- Misses 16739 16791 +52
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
JAORMX
left a comment
There was a problem hiding this comment.
Thanks for tracking this down! The issue makes sense. We should support deployments where the upstream OAuth/DCR endpoints are only reachable through a forward proxy.
The part I would change is enabling this for every client built here. This builder is also used for registry access, discovery, and JWT/JWKS validation. For deployments that already have proxy variables set, this changes those paths too, even though they previously connected directly. Matching http.DefaultTransport is not enough to establish that all of these clients should share its routing policy.
So, I agree with @jhrozek on making this explicit, along the lines of WithProxyFromEnvironment, and reviewing which callers should enable it rather than changing the shared default.
We also need to sort out the interaction with WithPrivateIPs. Reaching a private proxy and allowing private destinations are different decisions, so I would not recommend AllowPrivateIPs as a general workaround. Some consumers deliberately keep that disabled. An opt-in limits the scope of the change, but we still need to preserve the destination restrictions for the flows that use it. We can work through the security-sensitive details separately.
The new test is useful for catching a missing assignment. Before merging, we also need tests for the supported proxy path, NO_PROXY, and the interaction with the private-IP policy. That is our transport wiring and policy we need to test, not a reimplementation of the Go proxy tests. Please document the chosen behavior alongside the builder option too.
Requesting changes for those policy and compatibility questions. The proxy support itself is worth adding.
Problem
HttpClientBuilder.Build()builds itshttp.Transportwithout aProxyfield.HTTP_PROXY/HTTPS_PROXY/NO_PROXY(a zero-valuehttp.TransporthasProxy: nil, unlikehttp.DefaultTransport).pkg/authserver/upstream/oauth2.go→newHTTPClientForHost→NewHostScopedClientBuilder().Build()).CloneDefaultTransportWithDialControl, which already setsProxy: http.ProxyFromEnvironment.flowchart LR Pod["MCPRemoteProxy pod<br/>(HTTPS_PROXY set)"] Pod -->|"tool-forwarding client<br/>CloneDefaultTransportWithDialControl"| P1["honors proxy"] Pod -->|"auth-server OAuth client<br/>Build → Proxy: nil"| P2["ignores proxy"] P1 --> FP["forward proxy"] --> UP1["upstream MCP host<br/>reachable"] P2 --> DIRECT["direct egress"] --> UP2["IP-allowlisted token<br/>endpoint → 403"] classDef ok fill:#e7f7ec,stroke:#2e7d32,color:#1b3d24; classDef bad fill:#fdecea,stroke:#c62828,color:#5b1a15; class P1,FP,UP1 ok; class P2,DIRECT,UP2 bad;Fixes #6671
Fix
Proxy: http.ProxyFromEnvironmenton the transport inBuild(), matchinghttp.DefaultTransportand the vMCP path.Proxy.Note
AllowPrivateIPsoption.Type of change
Test plan
task test) — addedTestHttpClientBuilder_BuildSetsProxyFromEnvironmentAPI Compatibility
v1beta1API (it only touchespkg/networking).Does this introduce a user-facing change?
Yes — HTTP clients built via
pkg/networking(including the auth server's upstream OAuth/DCR calls) now honorHTTP(S)_PROXY/NO_PROXY, so deployments behind an explicit forward proxy work as expected.