Skip to content

Fix: PATCH /dags pagination bug and document wildcard dag_id_pattern#63665

Open
justinpakzad wants to merge 1 commit intoapache:mainfrom
justinpakzad:fix/dags-patch-pause-with-tags
Open

Fix: PATCH /dags pagination bug and document wildcard dag_id_pattern#63665
justinpakzad wants to merge 1 commit intoapache:mainfrom
justinpakzad:fix/dags-patch-pause-with-tags

Conversation

@justinpakzad
Copy link
Contributor

@justinpakzad justinpakzad commented Mar 15, 2026


Currently the PATCH /dags endpoint only updates the first page of matching DAGs (default limit of 50), meaning if the filters match more than one page, only the first page gets paused/unpaused. This fixes that by iterating through all pages to collect all matching dag ids before applying the update.

Also added to the docstring to clarify that dag_id_pattern is required to match any dags, and that ~ or % can be passed as wildcards to match all.

closes: #50555

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    Claude Sonnet 4.5 (mainly for generating test dags)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@boring-cyborg boring-cyborg bot added the area:API Airflow's REST/HTTP API label Mar 15, 2026
@justinpakzad justinpakzad marked this pull request as ready for review March 15, 2026 19:19
@justinpakzad justinpakzad force-pushed the fix/dags-patch-pause-with-tags branch from c032f2c to 3b2f945 Compare March 15, 2026 19:19
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Mar 17, 2026
Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

This is not needed. I believe you can achieve this by passing ~ or % as a wildcard dag_id_search param.

This can be detailed in the endpoint documentation (docstring that ends up in the openAPI spec) and will avoid accident or adding more code.

Also there is a pagination bug. Only the first matching 25 dags will be unpaused, we need to iterate though all pages.

Do you mind reconverting this PR to fixing the pagination issue so we actually update all the dags that match the query, and also add some docstring to explain the wildcard pattern ?

[],
),
(
{"owners": ["test_owner"], "exclude_stale": False},
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test case for what you are trying to solve. (match any tags, multiple tags, and multiple dags patched)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

Comment on lines +343 to +347
[
dag_id_pattern.value is not None,
tags.value is not None and tags.value.tags,
owners.value,
]
Copy link
Member

Choose a reason for hiding this comment

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

It's hard to justify why 'paused' or exclude_stale are excluded from this check. (Only some filters contribute to the check which can seem confusing, can't unpause all paused dags)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I misunderstood and thought it made sense to exclude those as a safeguard so a user doesn't accidentally unpause all paused dags, but yea it's confusing. Will revert these changes since all that needs fixing is the pagination + documenting the wildcard search parameter (as you mentioned).

Comment on lines 356 to 370
dags_select, total_entries = paginated_select(
statement=select(DagModel),
filters=[
exclude_stale,
paused,
dag_id_pattern,
tags,
owners,
editable_dags_filter,
],
order_by=None,
offset=offset,
limit=limit,
session=session,
)
Copy link
Member

Choose a reason for hiding this comment

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

Here we need to iterate through the pages to get all of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will make that change. Thanks for pointing that out.

@justinpakzad justinpakzad force-pushed the fix/dags-patch-pause-with-tags branch from 3b2f945 to 34995d8 Compare March 21, 2026 17:51
@justinpakzad justinpakzad changed the title Fix: allow PATCH /dags to filter by tags/owners without dag_id_pattern Fix: PATCH /dags pagination bug and document wildcard dag_id_pattern Mar 21, 2026
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 ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3.0.1 v2 API /dags patch pause non-functional

3 participants