Skip to content

Return null from Java SDK getVariable for missing Variables - #75920

Open
aaron-y-chen wants to merge 2 commits into
apache:mainfrom
aaron-y-chen:java-sdk-variable-not-found-null
Open

aaron-y-chen wants to merge 2 commits into
apache:mainfrom
aaron-y-chen:java-sdk-variable-not-found-null

Conversation

@aaron-y-chen

Copy link
Copy Markdown
Contributor

Summary

Client.getVariable(key) in the Java SDK is documented (KDoc and java.rst) to return null when the Variable does not exist, but it threw ApiError instead. A task reading an optional Variable failed rather than falling back to a default, and since ApiError carries no error type, callers could only tell "missing" apart from real failures by parsing the message.

The supervisor reports a missing Variable as ErrorResponse(VARIABLE_NOT_FOUND). getVariable now handles it with communicateOrNullIf, the same way getTaskStateStore handles TASK_STORE_NOT_FOUND: VARIABLE_NOT_FOUND returns null, and any other error still raises ApiError.

Behavior change

java-sdk 1.0.0-beta1 shipped with the throwing behavior. Code that catches ApiError to detect a missing Variable now gets null instead.

Testing

  • CommsTest: VARIABLE_NOT_FOUND returns null; any other error response still raises ApiError.
  • E2E: WriteAndDeleteVariable reads the Variable back after deleting it and fails unless the result is null. Verified locally: the Dag run fails without the fix (ApiError: [VARIABLE_NOT_FOUND]) and succeeds with it.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code (Opus 5.5) following the guidelines

@aaron-y-chen

Copy link
Copy Markdown
Contributor Author

unrelated CI failure on bzip2/libbz2-1.0 in add-build-essential-extend

@aaron-y-chen
aaron-y-chen force-pushed the java-sdk-variable-not-found-null branch from 39fe516 to 84fd69a Compare October 30, 2026 16:53

This branch has not been deployed

No deployments
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