Airflow Trigger Rules

A trigger rule tells a task what to expect from the tasks before it. By default, a task runs only when all earlier tasks succeed. Trigger rules change that behavior, so you can build cleanup steps, alerts, and flexible joins.

The Group Project Picture

Picture a school group project with three students who each write one page. The teacher can set different rules for the final binding step. One rule says "bind only when all three finish." Another says "bind when at least one finishes." A third says "bind no matter what happened." Trigger rules offer the same choices.

 Student A ─┐
 Student B ─┼──►  Bind the report   ← trigger rule decides when this runs
 Student C ─┘

The Default Rule

The default rule is all_success. A task with this rule waits for every parent to succeed. One failed parent turns the child into upstream_failed, and the child never runs.

All Trigger Rules

RuleTask Runs When
all_successEvery parent succeeded (default)
all_failedEvery parent failed
all_doneEvery parent finished, in any state
all_skippedEvery parent was skipped
one_successAt least one parent succeeded
one_failedAt least one parent failed
one_doneAt least one parent succeeded or failed
none_failedNo parent failed. Skipped parents are fine
none_failed_min_one_successNo parent failed, and at least one succeeded
none_skippedNo parent was skipped
alwaysRuns regardless of parent states

How to Set a Rule

from airflow.operators.python import PythonOperator

cleanup = PythonOperator(
    task_id="cleanup",
    python_callable=remove_temp_files,
    trigger_rule="all_done",
)

Use Case 1: Cleanup That Always Runs

A pipeline creates temporary files. The cleanup task must delete them even when the main work fails. The rule all_done guarantees that.

extract ──► transform ──► load ──► cleanup (all_done)
                │
          even if this fails, cleanup still runs

Use Case 2: Alert on Failure

An alert task should fire only when something goes wrong. The rule one_failed sends the message only after a failure.

alert = PythonOperator(
    task_id="send_alert",
    python_callable=notify_team,
    trigger_rule="one_failed",
)

[extract, transform, load] >> alert

When all three tasks succeed, the alert task is skipped.

Use Case 3: Join After a Branch

A branch skips one of its paths. A join task with the default rule would see a skipped parent and skip itself. The rule none_failed_min_one_success fixes this.

            ┌──► path_a ──┐
 start ──►  │             ├──► join (none_failed_min_one_success)
 (branch)   └──► path_b ──┘
            one path runs, one is skipped

Use Case 4: Take the Fastest Source

Two providers deliver the same data. The rule one_success starts the next step as soon as either one arrives.

Rule Behavior Example

Assume three parents finish as success, failed, and skipped.

RuleDoes the Child Run?
all_successNo
all_doneYes
one_successYes
one_failedYes
none_failedNo
none_skippedNo

Common Mistakes

  • Leaving the default rule on a join task after a branch, which skips the join.
  • Using all_failed for an alert when one_failed fits better.
  • Using always for a task that needs real input data from its parents.

Key Takeaways

  • A trigger rule describes which parent states allow a task to start.
  • The default all_success works for most steps.
  • Use all_done for cleanup and one_failed for alerts.
  • Use none_failed_min_one_success for joins after branches.