aaron-y-chen opened a new pull request, #75920: URL: https://github.com/apache/airflow/pull/75920
## 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? - [X] Yes (please specify the tool below) Generated-by: Claude Code (Opus 5.5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
