Refresh bundle version in place when DAG serialization is unchanged#68336
Merged
ephraimbuddy merged 2 commits intoJun 15, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an Airflow core correctness issue where SerializedDagModel.write_dag() took the “unchanged serialized DAG” fast path and left DagVersion.bundle_version (and version_data) pointing at an older bundle commit, causing task re-runs requested “with latest bundle version” to execute stale code.
Changes:
- Refresh
DagVersion.bundle_version/version_datain place when the DAG serialization hash is unchanged (and bundle name is unchanged), instead of skipping the write entirely. - Update
DagCodesource in the same in-place refresh path so stored DAG code stays aligned with the refreshed bundle pointer. - Add unit tests covering the in-place bundle version refresh and the true no-op case when bundle metadata is unchanged.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
airflow-core/src/airflow/models/serialized_dag.py |
Updates the “hash unchanged” fast path to refresh bundle metadata (and DAG code) in place rather than leaving a stale bundle pointer. |
airflow-core/tests/unit/models/test_serialized_dag.py |
Adds regression tests ensuring bundle version refresh happens without creating new DagVersion rows and that identical bundle metadata remains a no-op. |
3a2583f to
64abe52
Compare
When a DAG bundle advances to a new version/commit but the DAG's serialized content is byte-identical, write_dag took the 'unchanged' fast path and left the latest DagVersion's bundle_version pinned to the old commit. Tasks resolve their code from ti.dag_version.bundle_version at run time, so new runs and reruns 'with the latest bundle version' executed an outdated commit. Refresh the latest version's bundle_version/version_data (and dag code) in place instead. This does not create a new DagVersion, avoiding version inflation on every bundle commit, while keeping the recorded bundle pointer current. closes: apache#67657
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
64abe52 to
e111b23
Compare
uranusjr
reviewed
Jun 15, 2026
uranusjr
approved these changes
Jun 15, 2026
Open
2 tasks
pgagnon
pushed a commit
to pgagnon/airflow
that referenced
this pull request
Jun 15, 2026
…pache#68336) * Refresh bundle version in place when DAG serialization is unchanged When a DAG bundle advances to a new version/commit but the DAG's serialized content is byte-identical, write_dag took the 'unchanged' fast path and left the latest DagVersion's bundle_version pinned to the old commit. Tasks resolve their code from ti.dag_version.bundle_version at run time, so new runs and reruns 'with the latest bundle version' executed an outdated commit. Refresh the latest version's bundle_version/version_data (and dag code) in place instead. This does not create a new DagVersion, avoiding version inflation on every bundle commit, while keeping the recorded bundle pointer current. closes: apache#67657 * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
imrichardwu
pushed a commit
to imrichardwu/airflow
that referenced
this pull request
Jun 16, 2026
…pache#68336) * Refresh bundle version in place when DAG serialization is unchanged When a DAG bundle advances to a new version/commit but the DAG's serialized content is byte-identical, write_dag took the 'unchanged' fast path and left the latest DagVersion's bundle_version pinned to the old commit. Tasks resolve their code from ti.dag_version.bundle_version at run time, so new runs and reruns 'with the latest bundle version' executed an outdated commit. Refresh the latest version's bundle_version/version_data (and dag code) in place instead. This does not create a new DagVersion, avoiding version inflation on every bundle commit, while keeping the recorded bundle pointer current. closes: apache#67657 * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
dingo4dev
pushed a commit
to dingo4dev/airflow
that referenced
this pull request
Jun 16, 2026
…pache#68336) * Refresh bundle version in place when DAG serialization is unchanged When a DAG bundle advances to a new version/commit but the DAG's serialized content is byte-identical, write_dag took the 'unchanged' fast path and left the latest DagVersion's bundle_version pinned to the old commit. Tasks resolve their code from ti.dag_version.bundle_version at run time, so new runs and reruns 'with the latest bundle version' executed an outdated commit. Refresh the latest version's bundle_version/version_data (and dag code) in place instead. This does not create a new DagVersion, avoiding version inflation on every bundle commit, while keeping the recorded bundle pointer current. closes: apache#67657 * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
RulerChen
pushed a commit
to RulerChen/airflow
that referenced
this pull request
Jun 16, 2026
…pache#68336) * Refresh bundle version in place when DAG serialization is unchanged When a DAG bundle advances to a new version/commit but the DAG's serialized content is byte-identical, write_dag took the 'unchanged' fast path and left the latest DagVersion's bundle_version pinned to the old commit. Tasks resolve their code from ti.dag_version.bundle_version at run time, so new runs and reruns 'with the latest bundle version' executed an outdated commit. Refresh the latest version's bundle_version/version_data (and dag code) in place instead. This does not create a new DagVersion, avoiding version inflation on every bundle commit, while keeping the recorded bundle pointer current. closes: apache#67657 * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a DAG bundle advances to a new version/commit but the DAG's serialized content is byte-identical, write_dag took the 'unchanged' fast path and left the latest DagVersion's bundle_version pinned to the old commit. Tasks resolve their code from ti.dag_version.bundle_version at run time, so new runs and reruns 'with the latest bundle version' executed an outdated commit.
Refresh the latest version's bundle_version/version_data (and dag code) in place instead. This does not create a new DagVersion, avoiding version inflation on every bundle commit, while keeping the recorded bundle pointer current.
closes: #67657