Skip to content

Honor proxy env in overridden default HTTP client#252

Merged
yotamazriel merged 1 commit into
masterfrom
fix-default-client-proxy
Jun 22, 2026
Merged

Honor proxy env in overridden default HTTP client#252
yotamazriel merged 1 commit into
masterfrom
fix-default-client-proxy

Conversation

@asafyehezkel

Copy link
Copy Markdown
Contributor

What

Restore proxy support on the HTTP client that replaces the global http.DefaultClient.

pkg/api/utils.go runs an init() that swaps http.DefaultClient for one built around a bare http.Transport{}. A bare transport has Proxy: nil, whereas the stock http.DefaultTransport sets Proxy: http.ProxyFromEnvironment. The override therefore disabled HTTP_PROXY/HTTPS_PROXY/NO_PROXY handling process-wide — including for the http.Get calls in the embedded helm-charts code (e.g. pkg/github release lookups and chart downloads).

The fix sets Proxy: http.ProxyFromEnvironment on the replacement transport.

Why

On a proxied/offline host, leap server install failed with:

Get "https://api.github.com/repos/tensorleap/helm-charts/releases?...": dial tcp: lookup api.github.com on 127.0.0.53:53: no such host

even with the correct HTTPS_PROXY exported. The transport never consulted the proxy env, so it resolved api.github.com directly (no direct internet) and failed. This blocked online-mode installs behind a corporate proxy.

Reviewer notes

  • One-line behavioral change; no exported signatures touched.
  • CustomRoundTripper's 401→ErrAuth behavior is unchanged.
  • go build ./... and go vet ./pkg/api/ pass.
  • Hosts running an older leap binary need a rebuild to pick this up.

🤖 Generated with Claude Code

NewDefaultClient replaces the global http.DefaultClient but built its
transport from a bare http.Transport{} (Proxy: nil), which dropped the
HTTP(S)_PROXY/NO_PROXY support that the stock http.DefaultTransport
provides via http.ProxyFromEnvironment. As a result every http.Get in
the CLI (and in the helm-charts code it embeds) ignored proxy settings,
so installs on proxied/offline hosts failed resolving api.github.com
directly instead of dialing the proxy.

Set Proxy: http.ProxyFromEnvironment on the replacement transport.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@yotamazriel yotamazriel merged commit 240875a into master Jun 22, 2026
2 checks passed
@yotamazriel yotamazriel deleted the fix-default-client-proxy branch June 22, 2026 13:58
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.

2 participants