Skip to content

Make the Variable value non-nullable in the Execution API - #76007

Merged
uranusjr merged 9 commits into
apache:mainfrom
astronomer:execution-api-non-null-values
Nov 6, 2026
Merged

uranusjr merged 9 commits into
apache:mainfrom
astronomer:execution-api-non-null-values

Conversation

@uranusjr

@uranusjr uranusjr commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Identified while reviewing #75920.

A successful Variable read never carries a null value. Variable.get raises KeyError when nothing is found, and the route turns that into a 404. The Execution API and supervisor schema still typed the value as str | None, so every generated client got a nullable type. This changes the Variable value's type to non-nullable in both, under version 2027-02-28, so null only means "not found". Clients pinned to an older Execution API or supervisor schema version can still send null, which keeps storing "None" as before.

The Task SDK allowed Variable.set(key, None), but the None was stringified into "None" before being sent through the wire, so reading the Variable back returns the string "None", not None. This now emits a deprecation warning; behavior is unchanged. The warning is a FutureWarning subclass, as in #55881, because Python's default filters hide a DeprecationWarning raised from a Dag module, and Dag authors would never see it. Core airflow.models.Variable.set(key, None) called outside a task is not changed.

The Go and TypeScript SDKs follow the in-repo supervisor schema, so their generated models now type the Variable value as a plain string, and their clients drop the handling for a null or non-string value. Their move to 2027-02-28 and Airflow 3.5.0 already happened in #75387. The Java SDK pins a published schema version and is unchanged; it will move in a follow-up once 2027-02-28 is published.

Comment thread go-sdk/capabilities.yaml Resolved
@uranusjr
uranusjr force-pushed the execution-api-non-null-values branch from 07d99ab to e5fc219 Compare November 5, 2026 09:30
@uranusjr
uranusjr requested a review from kaxil November 5, 2026 09:40
Comment thread ts-sdk/src/coordinator/client.ts Resolved
Comment thread ts-sdk/src/generated/supervisor.ts Resolved
A successful Variable read never carries a null value: a missing
Variable is a 404. The Execution API and supervisor schema still typed
the value as nullable, so generated clients got a nullable type.

Type the value as str in VariableResponse/VariablePostBody and in the
supervisor schema's VariableResult/PutVariable. Version 2027-02-28 of
both carries the change. An older client or runtime that sets a
Variable to null keeps storing the string "None", as before.

Setting a Variable to None from the Task SDK is now deprecated. It
still stores "None", but emits RemovedInAirflow4Warning.

The task and asset state store read endpoints now return 404 for a
stored JSON null, so a successful read never carries null. Writers
already reject null.
Downgrading to an older supervisor schema version re-validates against
Cadwyn's generated copies of the models, so isinstance checks against
the head classes fail there. Check the kind discriminator instead, and
run the test for both 2026-10-30, which the Java SDK pins, and the
current 2027-02-28.
The supervisor schema migrator runs request converters on the raw wire
dict before validating, so a PutVariable from a 2026-10-30 runtime with
no value key was also turned into "None" instead of failing validation.
Only convert when the key is present and null.

Replace the downgrade test that passed with or without the version
change with tests that pin it: a real value from an older runtime is
kept, a missing value is still rejected, and only the 2026-10-30
PutVariable accepts a null value.

Do the same for the Execution API: add an old-version PUT of a real
value that must be stored unchanged, and drop the GET tests, which
repeat the head-version tests and don't exercise this version change.
Python's default filters hide a DeprecationWarning raised from a Dag
module, so the RemovedInAirflow4Warning never reached the task log.
Warn with a new DeprecatedVariableNoneValueWarning instead, a
FutureWarning like DeprecatedImportWarning, which is shown by default
and still points at the caller's line.
The test only checked PutVariable, so dropping the VariableResponse
instruction from the supervisor version change still passed, even
though the 2026-10-30 VariableResult the Java SDK receives would then
be non-nullable. Run it for both models.
The deprecation tests passed with any stacklevel. Check that the
warning is attributed to the caller's line, not the SDK's own module.
The supervisor no longer accepts a null Variable value, so a plain-JS
setVariable(key, null) produced a frame it couldn't decode. It never
replied, and the call only failed at the 30s request timeout with a
generic error. Throw a TypeError up front instead, as the task state
store already does for invalid values.
A Variable can no longer hold a null value, so null from getVariable
only means the key is missing.
@uranusjr
uranusjr force-pushed the execution-api-non-null-values branch from 694c5ed to 0a79ac1 Compare November 6, 2026 03:39
@uranusjr
uranusjr enabled auto-merge (squash) November 6, 2026 03:40
@uranusjr
uranusjr merged commit f01f7ef into apache:main Nov 6, 2026
199 of 201 checks passed
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.

2 participants