-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Fix Outlet Event Extra Data is Empty in Task Instance Success Listener #54568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Outlet Event Extra Data is Empty in Task Instance Success Listener #54568
Conversation
|
Hi @uranusjr , would you mind have a look whenever you have time? Just want to make sure the fix is on the right direction and would appreciate if you have any feedback. thank you in advance! |
3eaf425 to
b6c3ac0
Compare
sjyangkevin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ashb , I made the updates to the test cases, and also attempted to update the ci pre-commit check logic. Would appreciate if you could have a look at it and feel free to provide further feedback.
Lee-W
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me, but would appreciate a second pair of eyes
7179e30 to
40c2c91
Compare
|
Mostly good, I would appreciate it if we could have someone more familiar with task-sdk to take another look, as this changes the behavior of context, which could have a huge impact. |
|
Hi @sjyangkevin, Thanks for your fix — I’ve applied it in my environment and everything is working smoothly now. Really appreciate your effort! Looking forward to seeing this included in the next Airflow release. |
|
Hi all, I would like to follow up on the PR. I think the major concern here probably is around the impact of the |
…cess Listener (apache#54568) (cherry picked from commit 6eb9d9e) Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com>
…57062) * [v3-1-test] Fix Outlet Event Extra Data is Empty in Task Instance Success Listener (#54568) (#57031) Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com> * [v3-1-test] Fix Extra Links translation key. (#57030) (#57040) (cherry picked from commit 8d71c07) Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com> * [v3-1-test] Fix dags list not rendering (#57037) (#57046) (cherry picked from commit 8668fe5) Co-authored-by: Pierre Jeambrun <pierrejbrun@gmail.com> * [v3-1-test] fix(scheduler): load dag_run eagering for execution API validation (#57010) (#57045) Co-authored-by: Wei Lee <weilee.rx@gmail.com> fix(scheduler): load dag_run eagering for execution API validation (#56916)" (#56943) * [v3-1-test] Fix dag list cache invalidation on favouriting a dag (#57039) (#57047) Fix dag list cache invalidation on favouriting a dag (cherry picked from commit 4e46212) Co-authored-by: Pierre Jeambrun <pierrejbrun@gmail.com> * [v3-1-test] Add new PL translations. (#56359) (#57055) (cherry picked from commit 6583b6d) * Add last missing translation for 3.1.1 (#57057) * [v3-1-test] Close German translation gaps for full UI translation 2025-10-21 (#56980) (#57048) * [v3-1-test] Fix: Adjust PanelButtons spacing and alignment (#56570) * fix: adjust PanelButtons spacing and alignment * Fix PanelButtons layout and button styling * Fix PanelButtons: use bg.subtle and remove unnecessary _hover (cherry picked from commit 4c35cd2) Co-authored-by: anshuksi282-ksolves <anshu.singh@ksolves.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com> Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com> Co-authored-by: Pierre Jeambrun <pierrejbrun@gmail.com> Co-authored-by: Wei Lee <weilee.rx@gmail.com> Co-authored-by: Jarek Potiuk <jarek@potiuk.com> Co-authored-by: anshuksi282-ksolves <anshu.singh@ksolves.com>
|
Hi @Lee-W , thanks for looking into it , sorry I didn't get the chance yet to make the updates suggested by @uranusjr due to very limited bandwidth in these few weeks; I am wondering if we still need to make that change, if so, I would like to push that change by around end of the week. thanks!
|
… of sort memory" error (#55589) (#57042) * [v3-1-test] Fix Outlet Event Extra Data is Empty in Task Instance Success Listener (#54568) (#57031) Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com> * [v3-1-test] fix get latest serialized_dag model query to prevent "Out of sort memory" error (#55589) * fix get latest serialized_dag model query * fix get latest serialized_dag model query * add db type check logic (cherry picked from commit 757db27) Co-authored-by: Jeongwoo Do <48639483+wjddn279@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com> Co-authored-by: Jeongwoo Do <48639483+wjddn279@users.noreply.github.com>
…57062) * [v3-1-test] Fix Outlet Event Extra Data is Empty in Task Instance Success Listener (#54568) (#57031) Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com> * [v3-1-test] Fix Extra Links translation key. (#57030) (#57040) (cherry picked from commit 8d71c07) Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com> * [v3-1-test] Fix dags list not rendering (#57037) (#57046) (cherry picked from commit 8668fe5) Co-authored-by: Pierre Jeambrun <pierrejbrun@gmail.com> * [v3-1-test] fix(scheduler): load dag_run eagering for execution API validation (#57010) (#57045) Co-authored-by: Wei Lee <weilee.rx@gmail.com> fix(scheduler): load dag_run eagering for execution API validation (#56916)" (#56943) * [v3-1-test] Fix dag list cache invalidation on favouriting a dag (#57039) (#57047) Fix dag list cache invalidation on favouriting a dag (cherry picked from commit 4e46212) Co-authored-by: Pierre Jeambrun <pierrejbrun@gmail.com> * [v3-1-test] Add new PL translations. (#56359) (#57055) (cherry picked from commit 6583b6d) * Add last missing translation for 3.1.1 (#57057) * [v3-1-test] Close German translation gaps for full UI translation 2025-10-21 (#56980) (#57048) * [v3-1-test] Fix: Adjust PanelButtons spacing and alignment (#56570) * fix: adjust PanelButtons spacing and alignment * Fix PanelButtons layout and button styling * Fix PanelButtons: use bg.subtle and remove unnecessary _hover (cherry picked from commit 4c35cd2) Co-authored-by: anshuksi282-ksolves <anshu.singh@ksolves.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com> Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com> Co-authored-by: Pierre Jeambrun <pierrejbrun@gmail.com> Co-authored-by: Wei Lee <weilee.rx@gmail.com> Co-authored-by: Jarek Potiuk <jarek@potiuk.com> Co-authored-by: anshuksi282-ksolves <anshu.singh@ksolves.com>
… of sort memory" error (#55589) (#57042) * [v3-1-test] Fix Outlet Event Extra Data is Empty in Task Instance Success Listener (#54568) (#57031) Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com> * [v3-1-test] fix get latest serialized_dag model query to prevent "Out of sort memory" error (#55589) * fix get latest serialized_dag model query * fix get latest serialized_dag model query * add db type check logic (cherry picked from commit 757db27) Co-authored-by: Jeongwoo Do <48639483+wjddn279@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com> Co-authored-by: Jeongwoo Do <48639483+wjddn279@users.noreply.github.com>
… en (#57060) (#57064) * [v3-1-test] Fix Outlet Event Extra Data is Empty in Task Instance Success Listener (#54568) (#57031) Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com> * [v3-1-test] Fix: Adjust PanelButtons spacing and alignment (#56570) (#57062) * [v3-1-test] Fix Outlet Event Extra Data is Empty in Task Instance Success Listener (#54568) (#57031) Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com> * [v3-1-test] Fix Extra Links translation key. (#57030) (#57040) (cherry picked from commit 8d71c07) Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com> * [v3-1-test] Fix dags list not rendering (#57037) (#57046) (cherry picked from commit 8668fe5) Co-authored-by: Pierre Jeambrun <pierrejbrun@gmail.com> * [v3-1-test] fix(scheduler): load dag_run eagering for execution API validation (#57010) (#57045) Co-authored-by: Wei Lee <weilee.rx@gmail.com> fix(scheduler): load dag_run eagering for execution API validation (#56916)" (#56943) * [v3-1-test] Fix dag list cache invalidation on favouriting a dag (#57039) (#57047) Fix dag list cache invalidation on favouriting a dag (cherry picked from commit 4e46212) Co-authored-by: Pierre Jeambrun <pierrejbrun@gmail.com> * [v3-1-test] Add new PL translations. (#56359) (#57055) (cherry picked from commit 6583b6d) * Add last missing translation for 3.1.1 (#57057) * [v3-1-test] Close German translation gaps for full UI translation 2025-10-21 (#56980) (#57048) * [v3-1-test] Fix: Adjust PanelButtons spacing and alignment (#56570) * fix: adjust PanelButtons spacing and alignment * Fix PanelButtons layout and button styling * Fix PanelButtons: use bg.subtle and remove unnecessary _hover (cherry picked from commit 4c35cd2) Co-authored-by: anshuksi282-ksolves <anshu.singh@ksolves.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com> Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com> Co-authored-by: Pierre Jeambrun <pierrejbrun@gmail.com> Co-authored-by: Wei Lee <weilee.rx@gmail.com> Co-authored-by: Jarek Potiuk <jarek@potiuk.com> Co-authored-by: anshuksi282-ksolves <anshu.singh@ksolves.com> * [v3-1-test] Add possibility of removing extra translations missing in en (#57060) Sometimes we rename/move translation - we did not have a tool to remove such dangling translations. Now we have. (cherry picked from commit 2314099) Co-authored-by: Jarek Potiuk <jarek@potiuk.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Kevin Yang <85313829+sjyangkevin@users.noreply.github.com> Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com> Co-authored-by: Pierre Jeambrun <pierrejbrun@gmail.com> Co-authored-by: Wei Lee <weilee.rx@gmail.com> Co-authored-by: Jarek Potiuk <jarek@potiuk.com> Co-authored-by: anshuksi282-ksolves <anshu.singh@ksolves.com>
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.
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.
Close: #52574
As discussed in #52574 , the outlet event extra data is empty because the task runner does not commit the asset changes to the database before calling the callbacks and the listeners. Also, every call to the
get_template_contextmethod create and return a newContextobject, which might not persist the changes made during the task execution. Therefore, a method to fix this issue is to add a cache to theget_template_contextmethod, ensuring all calls are operating on the same context object.Since
RuntimeTaskInstanceis a unhashable type,@functools.cachedoesn't work in this case. As an alternative, we probably can convert thecontextinto a property, and the runtime task instance will operate on the propertycontext. However, this implementation breaks the pre-commit hookcheck-template-context-variable-in-sync.airflow/scripts/ci/pre_commit/check_template_context_variable_in_sync.py
Lines 81 to 88 in d4f4b22
Any feedback regarding how to improve the current implementation for fixing the issue would be appreciated.
manual functional testing
Before making the change, on log line 9, the bottom of the screenshot. The extra field is empty

After making the change, on log line 9, the bottom of the screenshot. The extra field contains the asset event extra.

^ 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.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.