fix: support lowercase proxy environment variables#754
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors proxy environment variable handling by introducing helper methods (SetProxyEnvFallbacks and ProxyEnv) on the Config struct and updating the local runtime execution paths to use them. It also adds comprehensive unit tests for proxy configuration. The review feedback suggests adding nil checks to the new Config methods to prevent potential nil pointer dereferences, and clearing uppercase environment variables in the lowercase fallback test to avoid flakiness from the host environment.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| t.Setenv("http_proxy", "http://lowercase-http:8080") | ||
| t.Setenv("https_proxy", "http://lowercase-https:8443") | ||
| t.Setenv("no_proxy", "localhost,127.0.0.1") |
There was a problem hiding this comment.
The test TestConfigProxyLowercaseFallbacks can be flaky or fail if the host environment running the tests already has HTTP_PROXY, HTTPS_PROXY, or NO_PROXY set. Since envconfig.Process will populate cfg with those uppercase values first, the fallback logic won't be triggered, causing the assertions to fail. To make this test hermetic and independent of the host environment, explicitly clear the uppercase environment variables using t.Setenv before setting the lowercase ones.
| t.Setenv("http_proxy", "http://lowercase-http:8080") | |
| t.Setenv("https_proxy", "http://lowercase-https:8443") | |
| t.Setenv("no_proxy", "localhost,127.0.0.1") | |
| t.Setenv("HTTP_PROXY", "") | |
| t.Setenv("HTTPS_PROXY", "") | |
| t.Setenv("NO_PROXY", "") | |
| t.Setenv("http_proxy", "http://lowercase-http:8080") | |
| t.Setenv("https_proxy", "http://lowercase-https:8443") | |
| t.Setenv("no_proxy", "localhost,127.0.0.1") |
| func (config *Config) SetProxyEnvFallbacks() { | ||
| if config.HttpProxy == "" { |
There was a problem hiding this comment.
To prevent potential nil pointer dereference panics, it is safer to add a nil check for the config receiver before accessing its fields.
| func (config *Config) SetProxyEnvFallbacks() { | |
| if config.HttpProxy == "" { | |
| func (config *Config) SetProxyEnvFallbacks() { | |
| if config == nil { | |
| return | |
| } | |
| if config.HttpProxy == "" { |
| func (config *Config) ProxyEnv() []string { | ||
| env := []string{} |
Summary
http_proxy,https_proxy, andno_proxyas fallbacks when uppercase proxy config is not setTests
go test ./internal/types/appgo test ./internal/core/local_runtime -run '^$'Full
go test ./internal/core/local_runtimecurrently requiresuv; the integration tests fail locally withUV not found.Related issue: langgenius/dify#18752