potiuk commented on code in PR #30641:
URL: https://github.com/apache/airflow/pull/30641#discussion_r1166796752


##########
airflow/models/xcom_arg.py:
##########
@@ -332,7 +341,23 @@ def get_task_map_length(self, run_id: str, *, session: 
Session) -> int | None:
 
     @provide_session
     def resolve(self, context: Context, session: Session = NEW_SESSION) -> Any:
-        ti = context["ti"]
+        from airflow.models.taskinstance import TaskInstance
+
+        context_ti = context["ti"]
+        if isinstance(context_ti, TaskInstance):
+            ti = context_ti
+        else:
+            ti = (
+                session.query(TaskInstance)
+                .filter_by(
+                    dag_id=context_ti.dag_id,
+                    task_id=context_ti.task_id,
+                    run_id=context_ti.run_id,
+                    map_index=context_ti.map_index,
+                )
+                .one()
+            )
+

Review Comment:
   (For us it is important as this will also flag all the cases where we will 
have to implement AIP-44 equivalent, so having assert here is really helpful, 
and I am glad it actually is needed here- that was exactly the intention of 
adding 
    TaskInstancePydantic now to Context)



-- 
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]

Reply via email to