From 4705636584c4d15e426cd4f33ca79ae76bd7c0fc Mon Sep 17 00:00:00 2001 From: fghpdf Date: Thu, 8 Jan 2026 11:12:53 +0900 Subject: [PATCH 1/3] fix: support lowercase proxy environment variables fallback - Add fallback to lowercase http_proxy/https_proxy/no_proxy when uppercase versions are empty - Fixes langgenius/dify#18752 --- internal/types/app/default.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/types/app/default.go b/internal/types/app/default.go index 3fc9b10a2..1a29371dd 100644 --- a/internal/types/app/default.go +++ b/internal/types/app/default.go @@ -1,6 +1,8 @@ package app import ( + "os" + "github.com/langgenius/dify-cloud-kit/oss" "golang.org/x/exp/constraints" ) @@ -38,6 +40,11 @@ func (config *Config) SetDefault() { setDefaultInt(&config.PythonEnvInitTimeout, 120) setDefaultInt(&config.DifyInvocationWriteTimeout, 5000) setDefaultInt(&config.DifyInvocationReadTimeout, 240000) + + // fallback to lowercase proxy environment variables if uppercase is empty + setDefaultStringFromEnv(&config.HttpProxy, "http_proxy") + setDefaultStringFromEnv(&config.HttpsProxy, "https_proxy") + setDefaultStringFromEnv(&config.NoProxy, "no_proxy") if config.DBType == DB_TYPE_POSTGRESQL || config.DBType == DB_TYPE_PG_BOUNCER { setDefaultString(&config.DBDefaultDatabase, "postgres") } else if config.DBType == DB_TYPE_MYSQL { @@ -56,3 +63,9 @@ func setDefaultString(value *string, defaultValue string) { *value = defaultValue } } + +func setDefaultStringFromEnv(value *string, envKey string) { + if *value == "" { + *value = os.Getenv(envKey) + } +} From b1dc71bb31a738e3c84fe1eb84c8f9d86eed8910 Mon Sep 17 00:00:00 2001 From: fghpdf Date: Fri, 9 Jan 2026 13:45:12 +0900 Subject: [PATCH 2/3] refactor: use existing setDefaultString for proxy env fallback --- internal/types/app/default.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/internal/types/app/default.go b/internal/types/app/default.go index 1a29371dd..ae10f07e3 100644 --- a/internal/types/app/default.go +++ b/internal/types/app/default.go @@ -42,9 +42,9 @@ func (config *Config) SetDefault() { setDefaultInt(&config.DifyInvocationReadTimeout, 240000) // fallback to lowercase proxy environment variables if uppercase is empty - setDefaultStringFromEnv(&config.HttpProxy, "http_proxy") - setDefaultStringFromEnv(&config.HttpsProxy, "https_proxy") - setDefaultStringFromEnv(&config.NoProxy, "no_proxy") + setDefaultString(&config.HttpProxy, os.Getenv("http_proxy")) + setDefaultString(&config.HttpsProxy, os.Getenv("https_proxy")) + setDefaultString(&config.NoProxy, os.Getenv("no_proxy")) if config.DBType == DB_TYPE_POSTGRESQL || config.DBType == DB_TYPE_PG_BOUNCER { setDefaultString(&config.DBDefaultDatabase, "postgres") } else if config.DBType == DB_TYPE_MYSQL { @@ -63,9 +63,3 @@ func setDefaultString(value *string, defaultValue string) { *value = defaultValue } } - -func setDefaultStringFromEnv(value *string, envKey string) { - if *value == "" { - *value = os.Getenv(envKey) - } -} From 9dfa8967e4d46062172334a04b17b098f72ffadf Mon Sep 17 00:00:00 2001 From: fghpdf Date: Sat, 10 Jan 2026 09:18:11 +0900 Subject: [PATCH 3/3] fix: use os.LookupEnv to distinguish unset vs empty proxy variables - Changed proxy fallback logic to only activate when uppercase variables are not set - This allows users to explicitly disable proxy by setting uppercase variables to empty string - Addresses review feedback on PR #562 --- internal/types/app/default.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/types/app/default.go b/internal/types/app/default.go index ae10f07e3..83c4f2dcf 100644 --- a/internal/types/app/default.go +++ b/internal/types/app/default.go @@ -41,10 +41,16 @@ func (config *Config) SetDefault() { setDefaultInt(&config.DifyInvocationWriteTimeout, 5000) setDefaultInt(&config.DifyInvocationReadTimeout, 240000) - // fallback to lowercase proxy environment variables if uppercase is empty - setDefaultString(&config.HttpProxy, os.Getenv("http_proxy")) - setDefaultString(&config.HttpsProxy, os.Getenv("https_proxy")) - setDefaultString(&config.NoProxy, os.Getenv("no_proxy")) + // fallback to lowercase proxy environment variables if uppercase is not set + if _, ok := os.LookupEnv("HTTP_PROXY"); !ok { + config.HttpProxy = os.Getenv("http_proxy") + } + if _, ok := os.LookupEnv("HTTPS_PROXY"); !ok { + config.HttpsProxy = os.Getenv("https_proxy") + } + if _, ok := os.LookupEnv("NO_PROXY"); !ok { + config.NoProxy = os.Getenv("no_proxy") + } if config.DBType == DB_TYPE_POSTGRESQL || config.DBType == DB_TYPE_PG_BOUNCER { setDefaultString(&config.DBDefaultDatabase, "postgres") } else if config.DBType == DB_TYPE_MYSQL {