What if you could control complex workflows with just a simple rule instead of endless if-else checks?
Why Trigger rules (all_success, one_success, none_failed) in Apache Airflow? - Purpose & Use Cases
Imagine you have a complex workflow with many tasks, and you need to decide when the next task should run based on the success or failure of previous tasks. Doing this manually means checking each task's status one by one and writing complicated code to handle every possible case.
Manually tracking task outcomes is slow and error-prone. You might miss a failure or accidentally start a task too early. This can cause your whole workflow to break or produce wrong results, and debugging becomes a nightmare.
Trigger rules like all_success, one_success, and none_failed let you easily control when tasks run based on previous task results. They handle all the logic for you, so you just pick the rule that fits your need and trust Airflow to manage the rest.
if task1.status == 'success' and task2.status == 'success': run_next_task()
next_task = PythonOperator(
task_id='next_task',
trigger_rule='all_success',
...
)It enables reliable and clear workflow control without writing complex status checks, making your data pipelines robust and easier to maintain.
For example, in a data pipeline, you want to load data only if all previous data extraction tasks succeeded (all_success), or you want to send a notification if at least one task succeeded (one_success), or proceed only if no tasks failed (none_failed).
Manual task status checks are complicated and fragile.
Trigger rules simplify when tasks run based on others' results.
They make workflows more reliable and easier to manage.
Practice
Solution
Step 1: Understand the meaning of
This trigger rule requires every upstream task to complete successfully before the downstream task runs.all_successStep 2: Compare with other trigger rules
one_successruns if any upstream succeeds,none_failedruns if no upstream failed (some may be skipped), andall_failedruns only if all upstream failed.Final Answer:
all_success-> Option AQuick Check:
All upstream success =all_success[OK]
all_success [OK]- Confusing
one_successwithall_success - Thinking
none_failedmeans all succeeded - Assuming
all_failedruns on success
Solution
Step 1: Recall the trigger rule for running on any upstream success
The trigger ruleone_successruns the task if at least one upstream task succeeded.Step 2: Check syntax correctness
Settingtrigger_rule='one_success'is the correct syntax in Airflow task definition.Final Answer:
trigger_rule='one_success' -> Option DQuick Check:
At least one success = trigger_rule='one_success' [OK]
- Using
all_successinstead ofone_success - Misspelling trigger_rule or using wrong quotes
- Confusing
none_failedwithone_success
trigger_rule='none_failed', will it run?Solution
Step 1: Understand
This rule runs the task only if no upstream task has failed. If any upstream failed, it will not run.none_failedtrigger ruleStep 2: Analyze upstream task states
task3 failed, so the condition of no failures is false. Therefore, the downstream task will not run.Final Answer:
No, because one upstream task failed -> Option BQuick Check:
Any failure blocksnone_failedrun [OK]
none_failed won't run [OK]- Ignoring failed upstream tasks when using
none_failed - Confusing skipped with failed states
- Assuming
none_failedruns if some succeed
trigger_rule='one_success' but it never runs even though some upstream tasks succeed. What is the likely cause?Solution
Step 1: Check trigger_rule spelling and assignment
If the trigger_rule is misspelled or not properly set, Airflow defaults toall_success, causing the task not to run if not all upstream succeed.Step 2: Verify other conditions
Since some upstream succeed, and the task has dependencies, the most common cause is incorrect trigger_rule syntax.Final Answer:
The trigger_rule is misspelled or not set correctly -> Option CQuick Check:
Incorrect trigger_rule causes unexpected task skipping [OK]
- Assuming upstream failure when some succeeded
- Ignoring DAG paused state
- Not defining upstream dependencies
Solution
Step 1: Understand the requirement
The task should run if all upstream succeeded or if none failed but some were skipped. This means failures block the run, but skips do not.Step 2: Match with trigger rules
all_successrequires all succeed (no skips allowed).none_failedallows skips but no failures.one_successruns if any succeed, which is too loose.all_doneruns regardless of success or failure.Step 3: Choose the correct trigger rule
none_failedfits the requirement exactly.Final Answer:
none_failed-> Option AQuick Check:
No failures but allows skips =none_failed[OK]
none_failed to allow skips but no failures [OK]- Choosing
all_successwhich disallows skips - Using
one_successwhich is too permissive - Confusing
all_donewith failure conditions
Ready to prove it?
Pass the test and this pattern moves unknown
