kacpermuda commented on code in PR #70772:
URL: https://github.com/apache/airflow/pull/70772#discussion_r3683516431


##########
providers/openlineage/src/airflow/providers/openlineage/utils/utils.py:
##########
@@ -1073,18 +1080,27 @@ def team_name(cls, dagrun: DagRun) -> str | None:
         if hasattr(dagrun, "team_name"):
             return dagrun.team_name
 
+        # Best-effort: the scheduler stamps `_team_name` on ORM DagRun objects 
before
+        # listener hooks fire. It's a private attribute with no stability 
guarantee,
+        # so guard with hasattr and an isinstance check.
+        if hasattr(dagrun, "_team_name"):
+            return dagrun._team_name if isinstance(dagrun._team_name, str) 
else None
+
         try:
-            bundle_name = cls.dag_version_info(dagrun, "bundle_name")
-            if not isinstance(bundle_name, str):
+            from sqlalchemy.orm import object_session
+
+            session = object_session(dagrun)
+
+            if session is None:
                 return None
 
-            from airflow.models.dagbundle import DagBundleModel
+            from airflow.models.dag import DagModel
 
-            return DagBundleModel.get_team_name(bundle_name)
+            return DagModel.get_team_name(dagrun.dag_id, session=session)

Review Comment:
   The only reason was to avoid getting bundle_name, this method takes dag_id 
rather than bundle_name, so it's one less call that we have to make and less 
code to maintain.



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