Skip to content

Scope asset Dag and task references to readable Dags - #74836

Merged
potiuk merged 3 commits into
apache:mainfrom
potiuk:asset-nested-dag-refs-readable-filter
Oct 19, 2026
Merged

potiuk merged 3 commits into
apache:mainfrom
potiuk:asset-nested-dag-refs-readable-filter

Conversation

@potiuk

@potiuk potiuk commented Oct 16, 2026

Copy link
Copy Markdown
Member

GET /api/v2/assets, GET /api/v2/assets/{asset_id} and the UI GET /ui/assets endpoint return, for each asset, the scheduled_dags, producing_tasks and consuming_tasks references. The asset list itself is already scoped to the assets the user can read, but these nested references were returned unfiltered, so a user who can read an asset but only some of the Dags using it would still see the Dag IDs and task IDs of the other Dags.

This change narrows those three nested lists to the Dags the user can read, using the same ReadableDagsFilterDep already used by the queued-event and dependency-graph endpoints. The filtering lives in AssetResponse.from_asset_row, and the public list and detail endpoints now build their responses through that helper instead of duplicating its body. Users with read access to all Dags see no difference. The asset alias endpoints return no Dag references, and the UI dependency graph already filters by readable Dags, so neither needs a change.

Tests: new tests for the public list, public detail and UI list endpoints check that a user who can read only dag_a sees only dag_a references, that no references come back when no Dags are readable, and that every reference comes back when all Dags are readable. The pinned query counts go up by one for the readable-Dags lookup.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Opus 5 following the guidelines

The asset list and detail endpoints (public and UI) returned every
scheduled Dag, producing task and consuming task reference of an asset,
including ones that belong to Dags the requesting user cannot read.
Those nested references are now narrowed to the user's readable Dags.

Generated-by: Claude Opus 5 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
@boring-cyborg boring-cyborg Bot added the area:API Airflow's REST/HTTP API label Oct 16, 2026
@potiuk potiuk added the backport-to-v3-4-test Backport to v3-4-test label Oct 16, 2026
@potiuk potiuk added this to the Airflow 3.4.0 milestone Oct 16, 2026
@potiuk

potiuk commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

@pierrejeambrun @vincbeck Could one of you take a look? It's targeted at 3.4.0 and needs a review to make the cut on 2026-10-19.

@vatsrahul1001 vatsrahul1001 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.

Looks good to me. The references are narrowed in one place, the queries already eager-load all three relationships so there is no extra N+1, and the tests cover the list, detail and UI endpoints.

Comment thread airflow-core/src/airflow/api_fastapi/core_api/datamodels/assets.py Outdated
@vatsrahul1001

Copy link
Copy Markdown
Contributor

Could use reviews from @pierrejeambrun @vincbeck before merging.

With a None default, a caller that forgot the argument got every Dag and task reference back unfiltered. Without a default, each caller has to say whether the references are narrowed, so a new endpoint fails closed instead of leaking references to Dags the user cannot read.

Generated-by: Claude Opus 5
@potiuk
potiuk merged commit 99f2b86 into apache:main Oct 19, 2026
67 checks passed
@potiuk
potiuk deleted the asset-nested-dag-refs-readable-filter branch October 19, 2026 14:32
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-4-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-4-test PR Link

potiuk added a commit that referenced this pull request Oct 19, 2026
) (#75107)

* Scope asset Dag and task references to readable Dags

The asset list and detail endpoints (public and UI) returned every
scheduled Dag, producing task and consuming task reference of an asset,
including ones that belong to Dags the requesting user cannot read.
Those nested references are now narrowed to the user's readable Dags.

Generated-by: Claude Opus 5 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions

* Rename newsfragment to the PR number

Generated-by: Claude Opus 5 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions

* Require readable_dag_ids when building an asset response

With a None default, a caller that forgot the argument got every Dag and task reference back unfiltered. Without a default, each caller has to say whether the references are narrowed, so a new endpoint fails closed instead of leaking references to Dags the user cannot read.
(cherry picked from commit 99f2b86)


Generated-by: Claude Opus 5

Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
vatsrahul1001 pushed a commit that referenced this pull request Oct 20, 2026
) (#75107)

* Scope asset Dag and task references to readable Dags

The asset list and detail endpoints (public and UI) returned every
scheduled Dag, producing task and consuming task reference of an asset,
including ones that belong to Dags the requesting user cannot read.
Those nested references are now narrowed to the user's readable Dags.

Generated-by: Claude Opus 5 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions

* Rename newsfragment to the PR number

Generated-by: Claude Opus 5 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions

* Require readable_dag_ids when building an asset response

With a None default, a caller that forgot the argument got every Dag and task reference back unfiltered. Without a default, each caller has to say whether the references are narrowed, so a new endpoint fails closed instead of leaking references to Dags the user cannot read.
(cherry picked from commit 99f2b86)


Generated-by: Claude Opus 5

Co-authored-by: Jarek Potiuk <jarek@potiuk.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 backport-to-v3-4-test Backport to v3-4-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants