dstandish commented on code in PR #39259:
URL: https://github.com/apache/airflow/pull/39259#discussion_r1579989027


##########
airflow/models/taskinstance.py:
##########
@@ -3167,6 +3188,8 @@ def render_templates(
         # MappedOperator is useless for template rendering, and we need to be
         # able to access the unmapped task instead.
         original_task.render_template_fields(context, jinja_env)
+        if isinstance(self.task, MappedOperator):
+            self.task = context["ti"].task

Review Comment:
   So, this is an interesting one @potiuk. The way mapped operators are 
"expanded" or "unmapped"... it happens inside of 
`MappedOperator.render_template_fields`.  It does so by replacing the `task` 
attr on the `ti` in the context dictionary, which in the non-db-isolation case 
mutates what is here `self.task`!  But in db isolation case, the context dict 
is created via RPC and so the pydantic TI in the context dict is not the same 
as the PydanticTI that is running....  it's .... quite complicated.  But anyway 
this here is one way to ensure that the task gets properly unmapped -- we don't 
here rely on mutating the TI in the context dict.



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