Lee-W commented on code in PR #53532:
URL: https://github.com/apache/airflow/pull/53532#discussion_r2217341939


##########
task-sdk/src/airflow/sdk/definitions/mappedoperator.py:
##########
@@ -736,7 +736,19 @@ def unmap(self, resolve: None | Mapping[str, Any]) -> 
BaseOperator:
             is_setup = kwargs.pop("is_setup", False)
             is_teardown = kwargs.pop("is_teardown", False)
             on_failure_fail_dagrun = kwargs.pop("on_failure_fail_dagrun", 
False)
-            kwargs["task_id"] = self.task_id
+
+            # Fix task_id duplication issue: if task_group is present and has 
prefix enabled,
+            # strip the prefix from task_id to avoid double prefixing when 
BaseOperator.__init__ is called
+            if self.task_group and self.task_group.prefix_group_id:
+                # Strip the task group prefix to avoid double prefixing
+                prefix = f"{self.task_group.group_id}."
+                if self.task_id.startswith(prefix):
+                    kwargs["task_id"] = self.task_id[len(prefix) :]
+                else:
+                    kwargs["task_id"] = self.task_id
+            else:
+                kwargs["task_id"] = self.task_id

Review Comment:
   We think we should handle it 
https://github.com/apache/airflow/blob/d6db4acaacc0842a6d1276d6199fcefe7d848bc7/task-sdk/src/airflow/sdk/bases/operator.py#L1025-L1027



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to