You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "giannistbs (via GitHub)" <gi...@apache.org> on 2025/04/22 12:24:44 UTC
[PR] Add support for restricting DAG trigger types (#40990) [airflow]
giannistbs opened a new pull request, #49548:
URL: https://github.com/apache/airflow/pull/49548
# Add support for restricting DAG trigger types
## Description
This PR implements the ability to restrict which trigger types are allowed for a DAG. This feature allows DAG authors to specify which trigger types (UI, REST API, CLI, etc.) should be disallowed for their DAGs, providing better security and operational control.
Closes #40990
## Type of change
- [x] New feature (non-breaking change which adds functionality)
- [x] This change requires a documentation update
## Implementation Details
1. Added a new `disallowed_trigger_types` column to the `dag` table to store the list of disallowed trigger types
2. Created a new `DagRunTriggerDisallowedError` exception class
3. Updated the DAG model to check for disallowed trigger types before creating a DAG run
4. Enhanced API endpoints to handle the new exception and return appropriate HTTP responses
5. Updated response models to include the disallowed trigger types information
## Example Usage
DAG authors can now specify disallowed trigger types when defining their DAGs:
```python
from airflow import DAG
from airflow.utils.types import DagRunTriggeredByType
dag = DAG(
dag_id='sensitive_data_pipeline',
schedule_interval='@daily',
# Prevent triggering via UI or REST API
disallowed_trigger_types=[DagRunTriggeredByType.UI, DagRunTriggeredByType.REST_API],
# other DAG parameters...
)
```
## Testing
- [x] Unit tests added for the new functionality
- [x] Integration tests added for API endpoints
- [x] Migration tests added for the new database column
## Documentation
- [x] Updated DAG documentation to include the new parameter
- [x] Added examples of how to use the feature
- [x] Updated API documentation to reflect the new error responses
## Related Issues
- Closes #40990
## Checklist
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream modules
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for restricting DAG trigger types (#40990) [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on PR #49548:
URL: https://github.com/apache/airflow/pull/49548#issuecomment-2832585833
Cli for triggering is also mostly going away, replaced by airflowctl - which also uses the API. So, no, not to me. But my view is just one view
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for restricting DAG trigger types (#40990) [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #49548:
URL: https://github.com/apache/airflow/pull/49548#issuecomment-2960862688
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for restricting DAG trigger types (#40990) [airflow]
Posted by "giannistbs (via GitHub)" <gi...@apache.org>.
giannistbs commented on PR #49548:
URL: https://github.com/apache/airflow/pull/49548#issuecomment-2832500348
Thank you for your feedback!
Given that distinction between UI and API triggers is no longer meaningful, would it make sense to instead focus on restricting CLI-triggered runs?
Since the CLI (airflow dags trigger) operates separately from the REST API, it seems there could still be value in allowing DAG authors to disallow manual CLI-triggered runs while permitting triggers via the API/UI.
Do you think this would be a useful and appropriate feature for Airflow 3.x?
If so, I would be happy to adjust the implementation accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for restricting DAG trigger types (#40990) [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #49548: Add support for restricting DAG trigger types (#40990)
URL: https://github.com/apache/airflow/pull/49548
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for restricting DAG trigger types (#40990) [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on PR #49548:
URL: https://github.com/apache/airflow/pull/49548#issuecomment-2821257446
This won't work. In airflow 3 there is no difference between the UI and the API anymore, since the UI uses the API.
Also: _Why_ do you want to do this? I don't see the purpose for this -- if a user has permissions to create a DagRun, then it shouldn't matter by which "frontend" they create it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for restricting DAG trigger types (#40990) [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #49548:
URL: https://github.com/apache/airflow/pull/49548#issuecomment-2821165681
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:
- Pay attention to the quality of your code (ruff, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-pre-commit-hooks) will help you with that.
- In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
- Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
- Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
- Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
- Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
- Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
Apache Airflow is a community-driven project and together we are making it better 🚀.
In case of doubts contact the developers at:
Mailing List: dev@airflow.apache.org
Slack: https://s.apache.org/airflow-slack
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for restricting DAG trigger types (#40990) [airflow]
Posted by "bugraoz93 (via GitHub)" <gi...@apache.org>.
bugraoz93 commented on PR #49548:
URL: https://github.com/apache/airflow/pull/49548#issuecomment-2832605387
I agree with Ash. We will leverage API functionality with CLI in airflowctl. This will allow us to move towards more isolation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org