From e6bbcadd7a2f5e3bc7e77f7a11b2ac044ed07761 Mon Sep 17 00:00:00 2001 From: shaealh Date: Tue, 14 Jul 2026 20:35:21 -0700 Subject: [PATCH] Keep Go SDK variable lookups consistent --- go-sdk/pkg/execution/client.go | 8 +------- go-sdk/sdk/client.go | 5 +++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/go-sdk/pkg/execution/client.go b/go-sdk/pkg/execution/client.go index 8ca5ada1af40e..ed57d4964c73d 100644 --- a/go-sdk/pkg/execution/client.go +++ b/go-sdk/pkg/execution/client.go @@ -22,8 +22,6 @@ import ( "encoding/json" "errors" "fmt" - "os" - "strings" "github.com/apache/airflow/go-sdk/pkg/api" "github.com/apache/airflow/go-sdk/pkg/execution/genmodels" @@ -72,11 +70,7 @@ func NewCoordinatorClient(comm *CoordinatorComm) *CoordinatorClient { // GetVariable requests a variable value from the supervisor. func (c *CoordinatorClient) GetVariable(ctx context.Context, key string) (string, error) { - // TODO: this duplicates variableFromEnv in sdk/client.go. The env-first - // precedence is part of the SDK contract, so both clients should share a - // single helper (e.g. an exported sdk.VariableFromEnv) instead of two - // independent copies that can drift. - if env, ok := os.LookupEnv(sdk.VariableEnvPrefix + strings.ToUpper(key)); ok { + if env, ok := sdk.VariableFromEnv(key); ok { return env, nil } diff --git a/go-sdk/sdk/client.go b/go-sdk/sdk/client.go index 61a8a56f8bb1c..4290fd5e1e30d 100644 --- a/go-sdk/sdk/client.go +++ b/go-sdk/sdk/client.go @@ -41,13 +41,14 @@ func NewClient() Client { return &client{} } -func variableFromEnv(key string) (string, bool) { +// VariableFromEnv returns the AIRFLOW_VAR_ value and whether it is set. +func VariableFromEnv(key string) (string, bool) { return os.LookupEnv(VariableEnvPrefix + strings.ToUpper(key)) } func (*client) GetVariable(ctx context.Context, key string) (string, error) { // TODO: Let the lookup priority be configurable like it is in Python SDK - if env, ok := variableFromEnv(key); ok { + if env, ok := VariableFromEnv(key); ok { return env, nil }