Skip to content

[v3-3-test] Fix DAG.cli() crashing on dags pause and unpause (#72109) - #72565

Merged
henry3260 merged 1 commit into
v3-3-testfrom
backport-bcc430f-v3-3-test
Sep 5, 2026
Merged

henry3260 merged 1 commit into
v3-3-testfrom
backport-bcc430f-v3-3-test

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor
  • Fix DAG.cli() crashing on dags pause and unpause

A Dag file run as a script goes through DAG.cli(), whose parser drops
--dag-id and instead dispatches every subcommand with the Dag object as
a second positional argument. The pause and unpause handlers never
accepted it, so Dag authors got a TypeError instead of the command.

The handlers are only reachable this way from a Dag file, which is why
the regular airflow dags pause path has always worked and no test
covered the difference.

  • Ignore --treat-dag-id-as-regex when DAG.cli() supplies the Dag

The Dag-scoped parser drops --dag-id but keeps --treat-dag-id-as-regex,
so the flag survives into a context where the user has no pattern left
to supply. The Dag's own id was then read back as a pattern, and dag_ids
may contain dots, so an unanchored match could pause unrelated Dags.

Normalising the flag next to the dag_id it guards covers both of its
readers, including the confirmation prompt, rather than guarding each
reader in turn and leaving the next one to be found later.

  • Update airflow-core/tests/unit/cli/commands/test_dag_command.py

(cherry picked from commit bcc430f)

Co-authored-by: Y-C easoneason0905@gmail.com
Co-authored-by: Eason09053360 185830721+Eason09053360@users.noreply.github.com
Co-authored-by: Henry Chen henryhenry0512@gmail.com

* Fix DAG.cli() crashing on dags pause and unpause

A Dag file run as a script goes through DAG.cli(), whose parser drops
--dag-id and instead dispatches every subcommand with the Dag object as
a second positional argument. The pause and unpause handlers never
accepted it, so Dag authors got a TypeError instead of the command.

The handlers are only reachable this way from a Dag file, which is why
the regular `airflow dags pause` path has always worked and no test
covered the difference.

* Ignore --treat-dag-id-as-regex when DAG.cli() supplies the Dag

The Dag-scoped parser drops --dag-id but keeps --treat-dag-id-as-regex,
so the flag survives into a context where the user has no pattern left
to supply. The Dag's own id was then read back as a pattern, and dag_ids
may contain dots, so an unanchored match could pause unrelated Dags.

Normalising the flag next to the dag_id it guards covers both of its
readers, including the confirmation prompt, rather than guarding each
reader in turn and leaving the next one to be found later.

* Update airflow-core/tests/unit/cli/commands/test_dag_command.py

---------
(cherry picked from commit bcc430f)

Co-authored-by: Y-C <easoneason0905@gmail.com>
Co-authored-by: Eason09053360 <185830721+Eason09053360@users.noreply.github.com>
Co-authored-by: Henry Chen <henryhenry0512@gmail.com>
@henry3260
henry3260 marked this pull request as ready for review September 5, 2026 16:22
@henry3260
henry3260 merged commit 6f8ca04 into v3-3-test Sep 5, 2026
146 of 160 checks passed
@henry3260
henry3260 deleted the backport-bcc430f-v3-3-test branch September 5, 2026 17:10
@github-actions github-actions Bot added this to the Airflow 3.3.2 milestone Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Hi maintainer, this PR was merged without a milestone set.
We've automatically set the milestone to Airflow 3.3.2 based on: bug fix merged to version branch
If this milestone is not correct, please update it to the appropriate milestone.

This comment was generated by Milestone Tag Assistant.

vatsrahul1001 pushed a commit that referenced this pull request Sep 7, 2026
…#72565)

* Fix DAG.cli() crashing on dags pause and unpause

A Dag file run as a script goes through DAG.cli(), whose parser drops
--dag-id and instead dispatches every subcommand with the Dag object as
a second positional argument. The pause and unpause handlers never
accepted it, so Dag authors got a TypeError instead of the command.

The handlers are only reachable this way from a Dag file, which is why
the regular `airflow dags pause` path has always worked and no test
covered the difference.

* Ignore --treat-dag-id-as-regex when DAG.cli() supplies the Dag

The Dag-scoped parser drops --dag-id but keeps --treat-dag-id-as-regex,
so the flag survives into a context where the user has no pattern left
to supply. The Dag's own id was then read back as a pattern, and dag_ids
may contain dots, so an unanchored match could pause unrelated Dags.

Normalising the flag next to the dag_id it guards covers both of its
readers, including the confirmation prompt, rather than guarding each
reader in turn and leaving the next one to be found later.

* Update airflow-core/tests/unit/cli/commands/test_dag_command.py

---------
(cherry picked from commit bcc430f)

Co-authored-by: Y-C <easoneason0905@gmail.com>
Co-authored-by: Eason09053360 <185830721+Eason09053360@users.noreply.github.com>
Co-authored-by: Henry Chen <henryhenry0512@gmail.com>
@vatsrahul1001 vatsrahul1001 added the type:bug-fix Changelog: Bug Fixes label Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:CLI type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants