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 |
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.