Skip to content

Warn in UI when the same dag_id is registered from multiple files#68791

Open
spider-man-tm wants to merge 3 commits into
apache:mainfrom
spider-man-tm:warn-on-duplicate-dag-id
Open

Warn in UI when the same dag_id is registered from multiple files#68791
spider-man-tm wants to merge 3 commits into
apache:mainfrom
spider-man-tm:warn-on-duplicate-dag-id

Conversation

@spider-man-tm

@spider-man-tm spider-man-tm commented Jun 21, 2026

Copy link
Copy Markdown

This is a follow-up to #68678, which proposed raising an ImportError when the same dag_id is found in two different files.

Currently, when two files define the same dag_id, Airflow silently overwrites the existing Dag entry with whichever file is parsed last — no error, no warning, no trace in the UI. This means a mis-deployed file can invisibly destroy a production Dag, leaving operators with no indication of what happened or where the conflict originated.

@uranusjr pointed out that an ImportError would fire transiently on every legitimate file rename, since the old DB entry persists until stale_dag_threshold passes. This PR avoids that entirely by recording a DagWarning instead of blocking the parse.

The warning shows both file names and the dag_id so users can self-diagnose:

dag_id 'hoge' is now served from 'file_b.py' (bundle: 'default'), previously registered from 'file_a.py'
(bundle: 'default'). If 'file_a.py' was renamed or moved, this notice will clear on the next parse
cycle once the old file is no longer observed. If both files coexist with the same dag_id, rename one of
them to avoid non-deterministic behavior.

For file moves the warning is transient and self-clearing; for real duplicates it persists until resolved. The metric dag_processing.duplicate_dag_id is also emitted on each conflict.


Was generative AI tooling used to co-author this PR?

  • Yes — Claude Code (Sonnet 4.6)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-regenerated by scripts/in_container/run_generate_openapi_spec.py to reflect the new DUPLICATE_DAG_ID value added to DagWarningType.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-regenerated by pnpm codegen to reflect the new duplicate dag id value added to DagWarningType.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-regenerated by pnpm codegen to reflect the new duplicate dag id value added to DagWarningType.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add DUPLICATE_DAG_ID to DagWarningType to allow recording duplicate dag_id warnings in the dag_warning table.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update expected Pydantic validation error message to include the newly added 'duplicate dag id' enum value.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-regenerated by datamodel-codegen to reflect the new DUPLICATE_DAG_ID value added to DagWarningType.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant