Skip to content

Fix stale DAGs affecting source authorization - #73292

Closed
AbarnaaSree wants to merge 1 commit into
apache:mainfrom
AbarnaaSree:fix/73284-ignore-stale-dags-source
Closed

AbarnaaSree wants to merge 1 commit into
apache:mainfrom
AbarnaaSree:fix/73284-ignore-stale-dags-source

Conversation

@AbarnaaSree

Copy link
Copy Markdown

Fix stale DAGs affecting source authorization.

When a stale DAG shares the same relative_fileloc and bundle_name as an active DAG, it can incorrectly be included in the source authorization check. This may cause the DAG source to be redacted even when the user has read access to all active DAGs.

This change excludes stale DAGs from the authorization query.

Tests

  • Added a regression test for an unreadable colocated DAG marked as stale.
  • git diff --check passes.
  • Local focused test execution was blocked by the Breeze CI image build failing while downloading mprocs.

Issue

related: #73284


Was generative AI tooling used to co-author this PR?
  • Yes (ChatGPT)

Generated-by: ChatGPT following the [Airflow guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)

@AbarnaaSree
AbarnaaSree force-pushed the fix/73284-ignore-stale-dags-source branch from adb3af2 to 5fdc9f2 Compare September 18, 2026 18:12

@Eason09053360 Eason09053360 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the patch! Some suggestion.

fileloc=requested.fileloc,
relative_fileloc=requested.relative_fileloc,
bundle_name=requested.bundle_name,
is_paused=False,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fixture relies on is_stale defaulting to True, so it no longer models an active co-located Dag:

Suggested change
is_paused=False,
is_stale=False,

select(DagModel.dag_id).where(
DagModel.relative_fileloc == dag_model.relative_fileloc,
DagModel.bundle_name == dag_model.bundle_name,
DagModel.is_stale.is_(False),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When the requested Dag is stale too (e.g. its file was deleted), this filters out every row, file_dag_ids is empty, and the check is skipped, so a caller who can read that one Dag gets the whole file. Its stored source predates the removal, so could stale rows stay in that case, with a test for it?

Suggested change
DagModel.is_stale.is_(False),
# A stale Dag's stored source predates its removal and may define other stale Dags.
DagModel.is_stale.in_([False, dag_model.is_stale]),

@kaxil

kaxil commented Oct 1, 2026

Copy link
Copy Markdown
Member

Closing this. DagModel.is_stale defaults to True, so the new is_stale.is_(False) filter drops the co-located Dag in the existing colocated_unreadable_dag fixture, and test_source_is_redacted_when_caller_cannot_read_all_dags_in_file now fails in all four DB test jobs. The new test sets is_stale = True, which is already the default. And when the requested Dag is itself stale, the filter leaves no Dags to check, so the authorization check is skipped and the full file source is returned.

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

Labels

area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants