Skip to content

fix: support lowercase proxy environment variables#754

Open
jcj46548-ux wants to merge 2 commits into
langgenius:mainfrom
jcj46548-ux:fix-lowercase-proxy-env
Open

fix: support lowercase proxy environment variables#754
jcj46548-ux wants to merge 2 commits into
langgenius:mainfrom
jcj46548-ux:fix-lowercase-proxy-env

Conversation

@jcj46548-ux
Copy link
Copy Markdown

Summary

  • read lowercase http_proxy, https_proxy, and no_proxy as fallbacks when uppercase proxy config is not set
  • pass both uppercase and lowercase proxy variables to local plugin processes and dependency installation commands
  • add tests covering lowercase fallbacks, uppercase precedence, and generated proxy environment entries

Tests

  • go test ./internal/types/app
  • go test ./internal/core/local_runtime -run '^$'

Full go test ./internal/core/local_runtime currently requires uv; the integration tests fail locally with UV not found.

Related issue: langgenius/dify#18752

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. go Pull requests that update go code plugin-daemon labels Jun 6, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +91 to +93
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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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")

Comment on lines +8 to +9
func (config *Config) SetProxyEnvFallbacks() {
if config.HttpProxy == "" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To prevent potential nil pointer dereference panics, it is safer to add a nil check for the config receiver before accessing its fields.

Suggested change
func (config *Config) SetProxyEnvFallbacks() {
if config.HttpProxy == "" {
func (config *Config) SetProxyEnvFallbacks() {
if config == nil {
return
}
if config.HttpProxy == "" {

Comment on lines +20 to +21
func (config *Config) ProxyEnv() []string {
env := []string{}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To prevent potential nil pointer dereference panics, add a nil check for the config receiver before accessing its fields.

func (config *Config) ProxyEnv() []string {
	if config == nil {
		return nil
	}
	env := []string{}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code plugin-daemon size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant