Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add SetVariable and DeleteVariable to the Go SDK task client - #73084

Draft
henry3260 wants to merge 2 commits into
apache:mainfrom
henry3260:go-sdk-variable-write
Draft

Add SetVariable and DeleteVariable to the Go SDK task client#73084
henry3260 wants to merge 2 commits into
apache:mainfrom
henry3260:go-sdk-variable-write

Conversation

@henry3260

@henry3260 henry3260 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Why

The language SDK specification (contributing-docs/30_new_language_sdk.rst) requires every SDK to support the variable-read-write capability: a task must be able to read, write, and delete Airflow Variables. The Go SDK could only read them. The supervisor already handles PutVariable and DeleteVariable for Python tasks, and the matching message structs were already generated in genmodels, but Go tasks had no API to send them. This is the Go counterpart of the Java change in #72676.

What

  • go-sdk/sdk/sdk.go: add SetVariable(ctx, key, value, description string) error and DeleteVariable(ctx, key string) error to VariableClient, so they are also available through sdk.Client.
  • go-sdk/pkg/execution/client.go: implement both methods on CoordinatorClient by sending PutVariable / DeleteVariable to the supervisor. An empty description is sent as null, matching Python's Variable.set default. The description key is always present on the wire, because the supervisor requires it.
  • go-sdk/example/bundle/variablewrite/, go-sdk/example/bundle/main.go, go-sdk/dags/go_examples.py: a new variable_write_dag example whose Go task writes a Variable, then writes and deletes a scratch Variable.
  • go-sdk/cmd/airflow-go-pack/pack_integration_test.go: add the new Dag to the expected bundle manifest.
  • airflow-core/docs/authoring-and-scheduling/language-sdks/go.rst: document the new methods.

Adding methods to VariableClient means user-defined fakes that implement this interface must add the two methods. The example mocks in this repo are updated.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

Go tasks could read Airflow Variables but not write or delete them, so the
Go SDK did not meet the variable-read-write capability that language SDKs
must support. The supervisor already handles PutVariable and DeleteVariable,
so Go tasks only lacked a way to send them.
… read

The note only mentioned AIRFLOW_VAR_* environment variables, but reads go
through every secrets backend configured on the API server, so any of them
can hide a value written from Go. The Java SDK docs already describe this
precedence the same way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant