Skip to content

fix(task-sdk): raise exception on Variable.set and Variable.delete failures#69436

Closed
Alwaysgaurav1 wants to merge 1 commit into
apache:mainfrom
Alwaysgaurav1:fix/68537-task-sdk-variable-write-errors
Closed

fix(task-sdk): raise exception on Variable.set and Variable.delete failures#69436
Alwaysgaurav1 wants to merge 1 commit into
apache:mainfrom
Alwaysgaurav1:fix/68537-task-sdk-variable-write-errors

Conversation

@Alwaysgaurav1

Copy link
Copy Markdown

Description

Currently, in the Task SDK, Variable.set() and Variable.delete() route their requests through the supervisor Execution API, but they do not check if the response is an ErrorResponse. If the API rejects the write operation (for example, returning a 403 Forbidden due to per-task authorization policies), the error is silently swallowed, and the task reports a success status even though the variable was not modified/deleted.

This PR fixes that by:

  • Checking the supervisor response type inside _set_variable and _delete_variable in airflow/sdk/execution_time/context.py.
  • Raising an AirflowRuntimeError if the response is an ErrorResponse.
  • Adding unit tests in task-sdk/tests/task_sdk/definitions/test_variables.py to ensure that Variable.set() and Variable.delete() correctly raise AirflowRuntimeError when the Execution API returns an error response.

Closes: #68537

@Alwaysgaurav1
Alwaysgaurav1 force-pushed the fix/68537-task-sdk-variable-write-errors branch from b6fc59c to d0a0c03 Compare July 6, 2026 06:38
@Alwaysgaurav1
Alwaysgaurav1 force-pushed the fix/68537-task-sdk-variable-write-errors branch from d0a0c03 to c8761d0 Compare July 9, 2026 05:28

@amoghrajesh amoghrajesh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it seem to be a duplicate/rework of: #68542

@potiuk potiuk closed this Jul 9, 2026
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.

Task SDK: Variable.set/delete swallow API errors — a rejected write does not fail the task

3 participants