Skip to content

Conversation

@krasserm
Copy link

@krasserm krasserm commented Feb 9, 2026

Summary

  • Add Proxy: http.ProxyFromEnvironment to all custom http.Transport and bare http.Client instances so that HTTP_PROXY, HTTPS_PROXY, and ALL_PROXY environment variables are honored
  • Fixes DNS resolution failures (no such host) when running inside sandboxed environments that route traffic through HTTP/SOCKS proxies

Problem

A custom http.Transport{} defaults Proxy to nil, unlike http.DefaultTransport which uses http.ProxyFromEnvironment. The base transport in optionsForAccountScopes (and bare http.Client instances used for OAuth token exchanges) silently bypassed all proxy settings.

Changes

Seven locations fixed across four packages:

File Context
internal/googleapi/client.go:128 Primary transport for all Google API calls
internal/googleapi/client.go:81 OAuth token refresh client
internal/googleapi/service_account.go:23 Service account token exchange
internal/googleauth/token_check.go:32 Refresh token validation
internal/googleauth/token_email.go:38 Email lookup from token
internal/googleauth/accounts_server.go:526 User info fetching
internal/cmd/gmail_watch_cmds.go:319 Webhook delivery client

Test plan

  • New TestProxyEnvRespected verifies the full transport chain and OAuth client route through HTTP_PROXY
  • All existing tests pass
  • make lint and make fmt-check pass
  • Manual: run gogcli inside a proxy-gated sandbox and verify Gmail API calls succeed

🤖 Generated with Claude Code

Custom http.Transport instances default Proxy to nil, silently
bypassing proxy env vars. This breaks all network calls in sandboxed
environments that route traffic through HTTP/SOCKS proxies.

Add Proxy: http.ProxyFromEnvironment to every transport and bare
http.Client across all API call paths and OAuth token exchanges.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@seasonhuang
Copy link

same problem

@poison
Copy link

poison commented Feb 10, 2026

also experiencing this issue

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.

3 participants