Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Listener: Set task on sqlalchemy taskinstance object (#27167)
same as apache/airflow#21157 TaskListener API's contract promises to pass TaskInstance object to listener plugin. However, what happens is not 100% true - the object being passed is one that maps to current SQLAlchemy session. `_run_raw_task` before merging the TI operates on detached TaskInstance object, then merges it to current session. Since there is no attached object in the SQLAlchemy identity map, SQLAlchemy creates it, and it's this object that's being passed to the SQLAlchemy event listeners. The problem with that is that when creating new SQLAlchemy object, SQLAlchemy takes care about setting only database-mapped fields. The ones that are purely on the python side, like task aren't being set on the new object. This PR manually sets `task` on the new SQLAlchemy object, so that `on_task_instance_success` receives proper TaskInstance with task field set. GitOrigin-RevId: 395ad7110e53a30a5d33f648d1dd797482eb268c
- Loading branch information