Skip to content

Add allowed_run_types to whitelist specific dag run types#61833

Merged
guan404ming merged 8 commits intoapache:mainfrom
guan404ming:add-deny-dag-run-types
Feb 20, 2026
Merged

Add allowed_run_types to whitelist specific dag run types#61833
guan404ming merged 8 commits intoapache:mainfrom
guan404ming:add-deny-dag-run-types

Conversation

@guan404ming
Copy link
Member

@guan404ming guan404ming commented Feb 13, 2026

Related Issue

Closes #61710

Why

Allow dag authors to restrict which run types (manual, scheduled, backfill, asset-triggered) are permitted on a per-DAG basis.

How

  • Add allowed_run_types field to definition, DagModel, serialization, and a DB migration
  • Enforce the allow list in scheduler, trigger, backfill, and asset materialization API routes
  • Disable the trigger button in the UI when manual runs are not allowed
image
Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    Claude Code with Opus 4.6

  • 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 or {issue_number}.significant.rst, in airflow-core/newsfragments.

@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:DAG-processing area:db-migrations PRs with DB migration area:Scheduler including HA (high availability) scheduler area:task-sdk area:translations area:UI Related to UI/UX. For Frontend Developers. kind:documentation translation:default labels Feb 13, 2026
@guan404ming guan404ming force-pushed the add-deny-dag-run-types branch from d22c599 to 08df0af Compare February 13, 2026 10:39
@eladkal
Copy link
Contributor

eladkal commented Feb 15, 2026

Great work!
I'm having an issue with trying to run:

dag = DAG(
    ...
    schedule="@daily",
    deny_dag_run_types=DagRunType.MANUAL
)

I get

Traceback (most recent call last):
  File "/usr/python/lib/python3.11/enum.py", line 714, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/python/lib/python3.11/enum.py", line 1137, in __new__
    raise ve_exc
ValueError: 'm' is not a valid DagRunType

It's solved if I change deny_dag_run_types=[DagRunType.MANUAL].
I think we should allow also a single value... It makes things easier and shouldn't be too hard to fix

Copy link
Contributor

@eladkal eladkal left a comment

Choose a reason for hiding this comment

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

I think we are missing tests for cases like:

from airflow.utils.types import DagRunType
my_dag = DAG(
    ...,
    schedule=[example_asset]
    deny_dag_run_types = [DagRunType.ASSET_TRIGGERED]
)
from airflow.utils.types import DagRunType
my_dag = DAG(
    ...,
    schedule="@daily"
    deny_dag_run_types = [DagRunType.SCHEDULED]
)
from airflow.utils.types import DagRunType
my_dag = DAG(
    ...,
    schedule=None
    deny_dag_run_types = [DagRunType.MANUAL]
)

Test should verify broken dag message is raised for all these 3 cases

@eladkal eladkal added this to the Airflow 3.2.0 milestone Feb 15, 2026
@eladkal eladkal added the type:new-feature Changelog: New Features label Feb 15, 2026
@guan404ming guan404ming force-pushed the add-deny-dag-run-types branch 2 times, most recently from e4f3907 to dbbc219 Compare February 16, 2026 08:31
@guan404ming
Copy link
Member Author

guan404ming commented Feb 16, 2026

Test should verify broken dag message is raised for all these 3 cases

Thanks, just updated to make the tests covering more cased.

It's solved if I change deny_dag_run_types=[DagRunType.MANUAL]. I think we should allow also a single value... It makes things easier and shouldn't be too hard to fix

Sure, that is a nice suggestion. I've updated to support that and also fix some type issue there.

@guan404ming guan404ming force-pushed the add-deny-dag-run-types branch from 0bb60cb to e6c003b Compare February 16, 2026 15:57
@guan404ming
Copy link
Member Author

Thanks for all the comments. I just updated with @ashb review comments and will handle @jason810496's tomorrow!

@guan404ming guan404ming marked this pull request as draft February 16, 2026 16:05
@guan404ming guan404ming force-pushed the add-deny-dag-run-types branch from e6c003b to c05d343 Compare February 17, 2026 07:20
@guan404ming guan404ming marked this pull request as ready for review February 17, 2026 07:21
@guan404ming guan404ming force-pushed the add-deny-dag-run-types branch 2 times, most recently from 658c46a to 41b9a51 Compare February 17, 2026 08:50
@eladkal
Copy link
Contributor

eladkal commented Feb 19, 2026

@guan404ming did you address all comments? are we ready to merge?

@guan404ming
Copy link
Member Author

Yes, I think I have resolved all the comments and we could refine it if there is any issue after merging.

Copy link
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for the rapid update!

@guan404ming guan404ming force-pushed the add-deny-dag-run-types branch from de27d5a to b690c32 Compare February 19, 2026 16:21
@guan404ming
Copy link
Member Author

Hi @jason810496, thanks for your great catch. I just updated with your comments.

guan404ming and others added 8 commits February 20, 2026 11:42
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
Co-authored-by: Andrii Roiko <57030016+roykoand@users.noreply.github.com>
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
@guan404ming guan404ming force-pushed the add-deny-dag-run-types branch from b690c32 to aea76f1 Compare February 20, 2026 03:42
Copy link
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

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

Thanks @guan404ming!

@guan404ming guan404ming merged commit 0131897 into apache:main Feb 20, 2026
247 of 248 checks passed
@guan404ming
Copy link
Member Author

Thanks!

@guan404ming guan404ming deleted the add-deny-dag-run-types branch February 20, 2026 14:18
choo121600 pushed a commit to choo121600/airflow that referenced this pull request Feb 22, 2026
* Add deny_dag_run_types option to limit specific dag run types

Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>

* Add missing deny_dag_run_types to test expectations and CLI helper

* Support single value

Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>

* Update to use accept list

Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>

* Update tests

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>

* Refactor run type checks to use enum values directly

Co-authored-by: Andrii Roiko <57030016+roykoand@users.noreply.github.com>
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>

* Update to use the generated API model

Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>

* Update create_openapi_http_exception_doc

Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>

---------

Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
Co-authored-by: Andrii Roiko <57030016+roykoand@users.noreply.github.com>
Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.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 area:DAG-processing area:db-migrations PRs with DB migration area:Scheduler including HA (high availability) scheduler area:task-sdk area:translations area:UI Related to UI/UX. For Frontend Developers. kind:documentation translation:default type:new-feature Changelog: New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the option to limit specific dag run types

8 participants