Copilot commented on code in PR #68627:
URL: https://github.com/apache/airflow/pull/68627#discussion_r3420790353


##########
airflow-core/src/airflow/models/dagcode.py:
##########
@@ -190,4 +190,5 @@ def update_source_code(cls, dag_id: str, fileloc: str, *, 
session: Session = NEW
         if new_source_code_hash != latest_dagcode.source_code_hash:
             latest_dagcode.source_code = new_source_code
             latest_dagcode.source_code_hash = new_source_code_hash
-            session.merge(latest_dagcode)
+            # Keep fileloc aligned with the refreshed source.
+            latest_dagcode.fileloc = fileloc

Review Comment:
   `update_source_code()` only refreshes `fileloc` when the source hash 
changes. If a DAG file is moved/renamed without changing contents, this method 
is still called with the new `fileloc`, but it will currently leave the stored 
`DagCode.fileloc` stale (since the hash matches). To keep metadata accurate, 
update `fileloc` unconditionally (or at least when it differs), and only gate 
`source_code`/`source_code_hash` on the hash comparison.



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