Skip to content
Silver 5 min read · Failures 2 practice problems ↓

Trigger rules and run state

By default a task runs only when everything before it succeeded. That is right for most steps, and wrong for clean-up tasks and joins after a branch. Trigger rules change the condition. This lesson shows the useful ones.

Pipelines in production · Airflow · Silver · Failures, lesson 2 of 2

Read first: Retries, timeouts and callbacks (skip if you know it)

In plain words first

A relay runner normally starts only when the teammate before them finishes. But the person who packs up the kit after the race goes whatever happened, even if a runner dropped out.

A trigger rule is that condition for each tasktask: One step of a DAG, such as running a query or calling an API. Each run of a task for one date is a task instance. Learn more →: "all before me succeeded" by default, or "whatever happened", "at least one succeeded" and others.

all_success, the default

A task runs when all its upstream tasks succeeded. If one failed, it becomes upstream_failed; if one was skipped, it is skipped too. That is right for a chain of dependent steps and wrong for two kinds of task: clean-up that must always run, and alerts that should run only when something failed.

trigger_ruleRuns when the upstream tasks are...Typical use
all_successall successfulThe normal step
all_doneall finished, whatever their stateClean-up: delete temp tables, stop a cluster
one_failedany failed (does not wait for the rest)Send an alert
all_failedall failed or upstream_failedA fallback path
one_successany successful (does not wait)The first of several sources to arrive
none_failedall finished, none failed (skipped is fine)After optional steps
none_failed_min_one_successas none_failed, and at least one succeededThe join after a branch
alwaysimmediately, without waitingRarely: monitoring side tasks

How a run gets its state

When every task has finished, Airflow looks at the leaf tasks, the ones with nothing downstream. If any leaf is failed or upstream_failed, the run is failed; otherwise it succeeded. Upstream failures only count through the leaves. That rule plus all_done produces a classic surprise:

Python · dags/plays_rollup.py · clean-up as the leaf hides the failure
import pendulum
from datetime import timedelta
from airflow.sdk import DAG
from airflow.providers.standard.operators.bash import BashOperator

with DAG(
    dag_id="plays_rollup",
    schedule="0 3 * * *",
    start_date=pendulum.datetime(2026, 3, 1, tz="UTC"),
    catchup=True,
    default_args={"retries": 2, "retry_delay": timedelta(minutes=5)},
):
    ingest = BashOperator(task_id="ingest", bash_command="ingest_plays --day {{ ds }}")
    rollup = BashOperator(task_id="rollup", bash_command="rollup_plays --day {{ ds }}")
    drop_tmp = BashOperator(
        task_id="drop_tmp",
        bash_command="drop_tmp_tables --day {{ ds }}",
        trigger_rule="all_done"
    )

    ingest >> rollup >> drop_tmp

What the schedulerscheduler: The Airflow process that reads DAG files, creates runs when they are due, and queues the tasks whose upstream tasks are done. Learn more → does · deployed Mar 3, 10:00 UTC · grid as of Mar 3, 12:00 UTC · failing: rollup in the 2026-03-02 run · 0 3 * * * (CronTriggerTimetable)

task \ runMar 1
03:00
Mar 2
03:00
Mar 3
03:00
ingest
rollup3
drop_tmp

successfailed· the bar on top is the run's state; a number is how many tries

Look at the 2 March run: rollup failed after three tries, yet the run is green. Its only leaf, drop_tmp, ran (that is what all_done is for) and succeeded, so the run succeeded. Dashboards and alerts that watch run states never hear about the failure.

Clean up and still fail the run

  1. 1
    Setup and teardown. Mark the clean-up as a teardown: drop_tmp.as_teardown(setups=ingest). A teardown runs like all_done, but it is ignored when Airflow decides the run's state, so the run fails when rollup fails. This is the modern answer; Task groupstask group: A named box of related tasks in a DAG, shown collapsed in the UI and wired as one unit. Learn more →, setup and teardown covers it.
  2. 2
    A watcher task. Add a leaf with trigger_rule="one_failed" downstream of the real work, whose code raises an exception. It is skipped on good days and fails when anything failed, taking the run with it.
Python · the watcher pattern
from airflow.sdk import TriggerRule
from airflow.sdk.exceptions import AirflowFailException

# the enum, instead of the string
@task(trigger_rule=TriggerRule.ONE_FAILED, retries=0)
def fail_run_if_upstream_failed():
    raise AirflowFailException("Upstream work failed; failing this run on purpose.")

[ingest, rollup] >> fail_run_if_upstream_failed()

Common mistakes

  • Clean-up with the default all_success — It is skipped exactly when the work failed and the clean-up matters most.
  • A clean-up or alert task as the only leaf — The run is marked success even when the work failed.
  • one_failed alerts that wait for "the end" — one_failed fires as soon as one upstream fails; that is usually what you want.
  • all_done after a branch — It also runs when the branch it depends on failed.

Key takeaways

  • all_success (default): a failed upstream makes a task upstream_failed; a skipped one skips it.
  • all_done for clean-up, one_failed for alerts, none_failed_min_one_success to join branches.
  • A run's state comes from its leaves.
  • Teardowns or a watcher keep clean-up from hiding failures.

Interview prep

THE QUESTION

"A clean-up task with trigger_rule=all_done is the last task of a DAG. The main job fails but the run shows success. Why, and how do you fix it?"

A run's state comes from its leaf tasks once everything has finished. The clean-up is the only leaf; all_done made it run after the failure, it succeeded, so the run succeeded. Fixes: make the clean-up a teardown task (as_teardown with its setup), which runs like all_done but is ignored for the run state; or add a watcher leaf with trigger_rule=one_failed that raises, so any failure fails the run. Either way alerts based on run state fire again.

Avoid: "all_done on the clean-up task" as the whole answer, without noticing that the clean-up then decides the run's state.

Follow-ups · answer out loud, then open

Follow-up"What is the difference between none_failed and none_failed_min_one_success?"
Both wait for all upstream tasks and refuse to run if any failed. none_failed also runs when every upstream task was skipped; none_failed_min_one_success needs at least one success, so a branch join is skipped when nothing ran.
Scenario"You need a Slack alert when any of four extract tasks fails, as soon as it fails. How?"
An alert task downstream of the four with trigger_rule="one_failed": it fires as soon as one fails, without waiting for the others, and is skipped when all succeed. Or an on_failure_callback in default_args, which alerts per failed task without an extra task.
Trap"A failed task anywhere in the DAG fails the run."
The run state is computed from the leaf tasks once all tasks are finished. A failure that only reaches a leaf as a successful all_done task leaves the run successful.

Check yourself

3 questions

Task C (all_success) has upstream A (success) and B (skipped). What is C?

Show the answer

skipped. Under all_success, a skipped upstream task skips the task.

The only leaf of a run succeeded, but a task before it failed. What is the run's state?

Show the answer

success. Run state comes from the leaves.

Which rule fits an alert task that should fire as soon as something fails?

Show the answer

one_failed. one_failed runs as soon as one upstream task has failed.

Practise this

Problems that use this, graded on hidden tests

Keep going

Up next · new module: Control flow · 4 min read
Branching and short-circuiting
Choose a path at run time, skip the rest, and join the branches back together.

Related lessons

Previous: Retries, timeouts and callbacks

Primary sources: Trigger rules · Setup and teardown