Skip to content

[v3-3-test] Resolve the Dag's team when authorizing a Dag found by lookup (#70893) - #71107

Merged
vatsrahul1001 merged 1 commit into
v3-3-testfrom
backport-70893-v3-3-test
Aug 5, 2026
Merged

[v3-3-test] Resolve the Dag's team when authorizing a Dag found by lookup (#70893)#71107
vatsrahul1001 merged 1 commit into
v3-3-testfrom
backport-70893-v3-3-test

Conversation

@vatsrahul1001

Copy link
Copy Markdown
Contributor

Backport of #70893 to v3-3-test. When a Dag is resolved by lookup (asset materialize, wait-dag-run XCom check) rather than named by the caller, its team_name is now resolved via DagModel.get_team_name() and passed to the auth check — otherwise a team-aware auth manager is asked about a differently-scoped resource. The required infra is present on the branch (DagModel.get_team_name, DagDetails.team_name).

One conflict in assets.py imports: main also imports DagVersion there (from an unrelated main-only change), which #70893 does not use — resolved by adding only from airflow.models.dag import DagModel and dropping the unused DagVersion import (would otherwise be a ruff F401 on this branch). dag_run.py and tests applied cleanly.

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) following the guidelines — cherry-pick backport with one import-conflict resolution (documented above).

* Resolve the Dag's team when authorizing a Dag found by lookup

Two authorization checks build DagDetails(id=dag_id) without team_name:
materialize_asset, where the Dag is resolved from the asset, and the
XCom-specific check in wait_dag_run_until_finished. Every other call site
passes the team, resolved with DagModel.get_team_name.

A team-aware auth manager distinguishes a team-scoped Dag from a global one by
that field, so omitting it asks about a differently-scoped resource than the
one being acted on. In wait_dag_run_until_finished the route dependency already
resolves the team for its RUN check, so the two checks in the same handler
disagreed.

Resolve the team at both sites, reusing the request session.

* Cover the XCom authorization check with a team-scoped Dag

The existing wait-endpoint test uses a Dag with no team, where the resolved and
unresolved forms are indistinguishable, so nothing caught the second check asking
about a differently-scoped resource than the route dependency did.

* Update airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_run.py

Co-authored-by: Amogh Desai <amoghrajesh1999@gmail.com>

* Update airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_assets.py

Co-authored-by: Amogh Desai <amoghrajesh1999@gmail.com>

* Fix docstring indentation from the applied review suggestions

---------

Co-authored-by: Amogh Desai <amoghrajesh1999@gmail.com>
(cherry picked from commit f814598)
@vatsrahul1001 vatsrahul1001 added this to the Airflow 3.3.1 milestone Aug 4, 2026
@vatsrahul1001
vatsrahul1001 requested a review from rawwar as a code owner August 4, 2026 14:47
@vatsrahul1001 vatsrahul1001 added the type:bug-fix Changelog: Bug Fixes label Aug 4, 2026
@boring-cyborg boring-cyborg Bot added the area:API Airflow's REST/HTTP API label Aug 4, 2026
@vatsrahul1001
vatsrahul1001 merged commit c654696 into v3-3-test Aug 5, 2026
71 checks passed
@vatsrahul1001
vatsrahul1001 deleted the backport-70893-v3-3-test branch August 5, 2026 02:04
vatsrahul1001 added a commit that referenced this pull request Aug 5, 2026
#71107)

* Resolve the Dag's team when authorizing a Dag found by lookup

Two authorization checks build DagDetails(id=dag_id) without team_name:
materialize_asset, where the Dag is resolved from the asset, and the
XCom-specific check in wait_dag_run_until_finished. Every other call site
passes the team, resolved with DagModel.get_team_name.

A team-aware auth manager distinguishes a team-scoped Dag from a global one by
that field, so omitting it asks about a differently-scoped resource than the
one being acted on. In wait_dag_run_until_finished the route dependency already
resolves the team for its RUN check, so the two checks in the same handler
disagreed.

Resolve the team at both sites, reusing the request session.

* Cover the XCom authorization check with a team-scoped Dag

The existing wait-endpoint test uses a Dag with no team, where the resolved and
unresolved forms are indistinguishable, so nothing caught the second check asking
about a differently-scoped resource than the route dependency did.

* Update airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_run.py



* Update airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_assets.py



* Fix docstring indentation from the applied review suggestions

---------


(cherry picked from commit f814598)

Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
Co-authored-by: Amogh Desai <amoghrajesh1999@gmail.com>
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 type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants