Add Dag version diff tooling#69818
Draft
ephraimbuddy wants to merge 1 commit into
Draft
Conversation
Dag authors and operators need a reliable way to understand how two stored Dag versions differ without downloading serialized payloads or manually comparing implementation details. This provides a semantic comparison surface shared by the public API and the airflow dags version-diff command, with machine-readable and human-readable output for automation and investigation. Historical serialized Dags can use different schema shapes, so comparisons normalize task, schedule, dependency, and metadata state before calculating changes. Optional source and rendered-value data are explicitly classified as available, redacted, or unavailable, and source authorization is evaluated against each version's historical bundle to avoid exposing code across team boundaries. Malformed legacy payloads and missing historical data degrade to unavailable results instead of failing the whole request. The OpenAPI contract and regression coverage keep authorization, duplicate dependency handling, schema conversion, CLI parsing and output, and failure states aligned across the feature.
Contributor
Author
|
I will break this up into 3 parts. Please don't review yet |
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.
Why
Dag version history preserves multiple serialized states, but operators do not have a supported way to answer what changed between two versions. Provide a deterministic comparison that helps diagnose version growth without requiring users to download and manually inspect serialized Dag payloads.
Keep the result honest about Airflow's persistence boundary. Treat every comparison as an observed-state diagnostic of the data currently stored for each version, not as creation-time evidence. Report missing, malformed, or unsupported historical data as unavailable instead of treating it as an empty diff.
This implements the shared service, CLI, and public API. Keep the UI panel as a later follow-up.
What changes
max_changes, report truncation, and degrade unsafe canonicalization or missing payloads to an explicit unavailable result.airflow dags versions diffwith explicit version selection or--previous-to-latest, optional values and source, configurable limits, and table, plain, JSON, or YAML output.GET /api/v2/dags/{dag_id}/dagVersions/{base_version_number}/diff/{target_version_number}and the corresponding response models.DagCoderows as immutable historical snapshots.Compatibility and scope
Testing
breeze run pytest airflow-core/tests/unit/models/test_dag_version_diff.py airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_versions.py::TestGetDagVersionDiff airflow-core/tests/unit/cli/commands/test_dag_command.py::TestDagVersionDiffCommand airflow-core/tests/unit/cli/test_cli_parser.py::TestCli::test_dag_version_diff_parser -xvs— 50 passed..venv/bin/prek run mypy-airflow-core --all-files.venv/bin/prek run generate-openapi-spec --all-filesWas generative AI tooling used to co-author this PR?
Generated-by: Codex (GPT-5) following the guidelines