Skip to content

Conversation

@ashb
Copy link
Member

@ashb ashb commented Nov 5, 2025

As part of the fix in #54568 we made ti.get_runtime_context() return a
cached context key, which meant that when run() in the TaskSDK created a
copy via task.prepare_for_execution() the value previously in the context
was the previous copy.

Most of the time this doesn't matter, as the task object that is executed is
the correct value, it's just this is more correct for things like listeners.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@vatsrahul1001 vatsrahul1001 added the backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch label Nov 5, 2025
@kacpermuda
Copy link
Contributor

Thanks, that's a critical fix from the listener perspective !

@vatsrahul1001

This comment was marked as resolved.

As part of the fix in apache#54568 we made `ti.get_runtime_context()` return a
cached context key, which meant that when `run()` in the TaskSDK created a
copy via `task.prepare_for_execution()` the value previously in the context
was the previous copy.

Most of the time this doesn't matter, as the task object that is executed is
the correct value, it's just this is more correct for things like listeners.
@ashb ashb force-pushed the update-task-ti-cached--context branch from ed48efc to dd72e36 Compare November 5, 2025 17:53
@amoghrajesh amoghrajesh added this to the Airflow 3.1.3 milestone Nov 5, 2025
@vatsrahul1001 vatsrahul1001 merged commit 07e6ad7 into apache:main Nov 5, 2025
83 checks passed
@vatsrahul1001 vatsrahul1001 deleted the update-task-ti-cached--context branch November 5, 2025 18:49
github-actions bot pushed a commit that referenced this pull request Nov 5, 2025
Ensure `task` in the context is always correct.
(cherry picked from commit 07e6ad7)

Co-authored-by: Ash Berlin-Taylor <ash@apache.org>
@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Backport successfully created: v3-1-test

Status Branch Result
v3-1-test PR Link

github-actions bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 5, 2025
…7884)

Ensure `task` in the context is always correct.
(cherry picked from commit 07e6ad7)

Co-authored-by: Ash Berlin-Taylor <ash@apache.org>
vatsrahul1001 pushed a commit that referenced this pull request Nov 5, 2025
…57892)

Ensure `task` in the context is always correct.
(cherry picked from commit 07e6ad7)

Co-authored-by: Ash Berlin-Taylor <ash@apache.org>
xchwan pushed a commit to xchwan/airflow that referenced this pull request Nov 6, 2025
Ensure `task` in the context is always correct.
@ephraimbuddy ephraimbuddy added the type:bug-fix Changelog: Bug Fixes label Nov 10, 2025
ephraimbuddy pushed a commit that referenced this pull request Nov 10, 2025
…57892)

Ensure `task` in the context is always correct.
(cherry picked from commit 07e6ad7)

Co-authored-by: Ash Berlin-Taylor <ash@apache.org>
Copilot AI pushed a commit to jason810496/airflow that referenced this pull request Dec 5, 2025
Ensure `task` in the context is always correct.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:task-sdk backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants