You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "jason810496 (via GitHub)" <gi...@apache.org> on 2025/02/21 06:16:27 UTC

Re: [PR] AIP-65 | Add dag versions to DAGRunResponse [airflow]

jason810496 commented on code in PR #46484:
URL: https://github.com/apache/airflow/pull/46484#discussion_r1964911576


##########
airflow/models/dagrun.py:
##########
@@ -314,7 +314,11 @@ def validate_run_id(self, key: str, run_id: str) -> str | None:
     @property
     def dag_versions(self) -> list[DagVersion]:
         """Return the DAG versions associated with the TIs of this DagRun."""
-        dag_versions = list(dict.fromkeys(list(self._tih_dag_versions) + list(self._ti_dag_versions)))
+        dag_versions = [
+            dv
+            for dv in dict.fromkeys(list(self._tih_dag_versions) + list(self._ti_dag_versions))
+            if dv is not None
+        ]
         sorted_ = sorted(dag_versions, key=lambda dv: dv.id)

Review Comment:
   Encountered the following error, so I filtered out `None` in `dag_versions`.
   ```
   airflow/api_fastapi/core_api/routes/ui/dags.py:145: in recent_dag_runs
       dag_versions=dag_run.dag_versions,
   airflow/models/dagrun.py:321: in dag_versions
       sorted_ = sorted(dag_versions, key=lambda dv: dv.id)
   airflow/models/dagrun.py:321: in <lambda>
       sorted_ = sorted(dag_versions, key=lambda dv: dv.id)
   E   AttributeError: 'NoneType' object has no attribute 'id'
   ```



-- 
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-unsubscribe@airflow.apache.org

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