avolant opened a new pull request, #67545: URL: https://github.com/apache/airflow/pull/67545
### Summary `SerializedDagModel.write_dag` short-circuits when the DAG hash and bundle name are unchanged, returning before persisting the new `bundle_version`. As a result, redeploying a bundle (new commit / archive) where a given DAG file is byte-identical leaves the existing `DagVersion.bundle_version` row pointing at the previous commit, even though `DagFileProcessorManager._bundle_versions[bundle]` already reflects the new commit. Downstream callers that resolve "which bundle commit produced this DAG?" — for example the DAG source endpoint and task-instance/version history views — then return stale bundle artifacts (sibling files such as job definitions are served from the previous commit), which is surprising for users who redeploy a bundle expecting the new code to take effect. ### Fix Extend the short-circuit predicate with `dag_version.bundle_version == bundle_version`. If a bundle SHA change is observed for an otherwise-unchanged DAG, a new `DagVersion` row is created — mirroring the existing behaviour when `bundle_name` changes (covered by `test_new_dag_version_created_when_bundle_name_changes_and_hash_unchanged`). The fix is safe for `None` bundle versions: both sides are `None` for non-versioned bundles (e.g. `LocalDagBundle`), so the new term is a no-op there. ### Reproduction With a versioned `LocalDagBundle`-style bundle (`get_current_version()` returning the commit SHA) and `min_file_process_interval = 0` so the dag-processor re-queues the DAG on every refresh: 1. Deploy bundle at SHA `v1`, parse — `DagVersion.bundle_version = v1`. 2. Deploy a new bundle at SHA `v2` where the DAG `.py` is byte-identical (only sibling files change). `_bundle_versions[<bundle>] = v2`, but `write_dag` returns False at the short-circuit and `DagVersion.bundle_version` stays at `v1`. With this patch, step 2 creates a new `DagVersion` with `bundle_version = v2`. ### Test Added `test_new_dag_version_created_when_bundle_version_changes_and_hash_unchanged` next to the analogous `bundle_name` test in `airflow-core/tests/unit/models/test_serialized_dag.py`. --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (Claude Code) <!-- Generated-by: Claude Code following the guidelines --> -- 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]
