anshuksi282-ksolves commented on code in PR #56422:
URL: https://github.com/apache/airflow/pull/56422#discussion_r2417669798


##########
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:
   Hi @ephraimbuddy,
   
   Thanks for the suggestion!  I updated the code to use latest_ser_dag = 
dag_version.serialized_dag instead of cls.get(...).
   Null checks are still in place to ensure safety, and dynamic DAG updates now 
work reliably using the dag_version approach.
   
   The PR has been updated with this change.



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