ephraimbuddy commented on code in PR #56422:
URL: https://github.com/apache/airflow/pull/56422#discussion_r2417391159


##########
airflow-core/src/airflow/models/serialized_dag.py:
##########
@@ -427,22 +427,24 @@ def write_dag(
             # the serialized dag, the dag_version and the dag_code instead of 
a new version
             # if the dag_version is not associated with any task instances
             latest_ser_dag = cls.get(dag.dag_id, session=session)
-            if TYPE_CHECKING:
-                assert latest_ser_dag is not None
-            # Update the serialized DAG with the new_serialized_dag
-            latest_ser_dag._data = new_serialized_dag._data
-            latest_ser_dag._data_compressed = 
new_serialized_dag._data_compressed
-            latest_ser_dag.dag_hash = new_serialized_dag.dag_hash
-            session.merge(latest_ser_dag)
-            # The dag_version and dag_code may not have changed, still we 
should
-            # do the below actions:
-            # Update the latest dag version
-            dag_version.bundle_name = bundle_name
-            dag_version.bundle_version = bundle_version
-            session.merge(dag_version)
-            # Update the latest DagCode
-            DagCode.update_source_code(dag_id=dag.dag_id, fileloc=dag.fileloc, 
session=session)
-            return True
+            
+            if latest_ser_dag:  

Review Comment:
   If there's a dag_version then we should have serdag. Can you check if 
dag_version.serialized_dag would work? Should work, or we can improve the 
DagVersion.get_latest_version to load the serdag when getting the latest 
version.
   Something like this:
   `latest_ser_dag = dag_version.serialized_dag`



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