Repository navigation
Description
Apache Airflow version
Other Airflow 2 version (please specify below)
If "Other Airflow 2 version" selected, which one?
2.10.5
What happened?
I have a task that filters a list based on values of a second list. As such it depends on two upstream tasks, each producing one of the lists. The second upstream task is mapped dynamically.
With the default trigger rule all_success the task in question will skip if any of the mapped tasks skips, which feels counter-intuitive.
With the all_done trigger rule the task behaves as expected, waiting for all mapped tasks to finish and executing with the resulting mapped list of outputs.
However, if all of the mapped tasks skip, which is a valid result in this context, the tasks still tries to execute.
This might be related to #51320.
What you think should happen instead?
The task receives the original list and instead of the second list with filter values it receives None. I think this happens because the mapped return values of skipped tasks (None) are reduced to None.
In my opinion it would be more appropriate to reduce them to [].
Apart from that, the task should just be skipped.
How to reproduce
from random import random
from typing import Any, List
import pendulum
from airflow.decorators import dag, task
from airflow.exceptions import AirflowSkipException
from airflow.models.param import Param
@dag(
"playground",
"Try things",
schedule=None,
start_date=pendulum.now(),
params={
"p_abort": Param(
type="number",
title="p_abort",
minimum=0.0,
maximum=1.0,
description="Probability to abort mapped tasks",
)
},
)
def playground():
@task.python
def produce_list() -> List[int]:
return list(range(25))
@task.python
def maybe_abort(value: int, **kwargs) -> int:
if random() > kwargs["params"]["p_abort"]:
return value
raise AirflowSkipException()
@task.python
def filter_list(values1: List[int], values2: List[int]) -> List[int]:
# if values1 is None or values2 is None:
# raise AirflowSkipException()
return [v for v in values1 if v in values2]
values1 = produce_list()
values2 = maybe_abort.expand(value=values1)
filter_list.override(trigger_rule="all_done")(values1, values2)
playground()
if __name__ == "__main__":
playground().test()This issue can be worked around with the commented check, but I don't think we should have to validate task inputs.
Operating System
Ubuntu 24.04
Versions of Apache Airflow Providers
No response
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
jroachgolf84 commentedon Jul 23, 2025
@Chais - correct me if I'm wrong, but there are two conditions here that you've outlined.
all_donetrigger rule, when all Tasks skip, the downstream Task still executes.all_successtrigger rule, when at least one Task skips, the downstream Task skips.As far as I can tell, this is the expected behavior. For
all_done, the skipped Tasks have in fact reached a terminal state, meaning they are "done", and downstream execution should occur. Forall_success, a skipped Task is NOT considered a success, to downstream execution should NOT occur.There's a nice guide here that walks through these trigger rules: https://www.astronomer.io/blog/understanding-airflow-trigger-rules-comprehensive-visual-guide/
Chais commentedon Jul 23, 2025
When you put it like that it makes a lot of sense.
It does however raise the question which trigger rule would be appropriate to use?
I have a reduce task that depends on a mapped task, providing the the selectors, that can have zero or more successes, with the remainder being skipped, and a "regular" task, providing the population, that is effectively guaranteed to succeed. I want the task to execute as long as there is at least one success in the mapped tasks or skip if they all skip. Should the regular task fail, then so should the reduce task.
jroachgolf84 commentedon Jul 23, 2025
Would the
one_successtrigger rule work for that?https://www.astronomer.io/blog/understanding-airflow-trigger-rules-comprehensive-visual-guide/
Chais commentedon Jul 23, 2025
No, because the "guaranteed" success of the task providing the unfiltered list counts toward that.
aayushbisen commentedon Jul 24, 2025
Hey @Chais I am trying to reproduce the issue in my local env. I'm new to the project can you help me pointing to Airflow v2?
Chais commentedon Jul 24, 2025
What do you mean? The DAG to reproduce the issue is above. For development I use a local Python Virtualenv managed by Poetry and run
airflow standalonefrom there. Anything more is probably outside the scope of this ticket.aayushbisen commentedon Jul 24, 2025
My local env is running airflow v3 using breeze cli and the issue is noticed in v2 so wanted to check if I can point to v2 and reproduce it?
Chais commentedon Jul 24, 2025
I'm not familiar with breeze. I told you how I set up my environment. Again, setting up your local dev environment is beyond the scope of this ticket. I expect however, that this reproduces in v3, too. As jroachgolf84 mentioned, this seems to be intended behaviour.
aayushbisen commentedon Jul 28, 2025
@jroachgolf84 do you think we need a new trigger rule for the type of scenario discussed in this issue?
cdagraca commentedon Dec 29, 2025
I'm seeing some odd behaviour in 2.10.3 that I think relates to this.
When my "all_done" task has 2 upstream tasks, one of which succeeds and the other is skipped, it gets skipped.
When it has only one upstream task, and this gets skipped, the task executes.
I could accept the argument that the skipped task(s) have "reached a terminal state" and so count as "done" if it was consistent in both cases, but in practice skipped only sometimes counts as done with respect to an "all_done" rule.
I can work around this in my current use case, just adding this in case it helps with tracking this down.
The bottom DAG is a simplified version of the top one:
ETA: Putting back in the otherwise unneeded dependency directly from the first to the last task makes the second DAG behave as expected
kaxil commentedon Oct 1, 2026
In Airflow 3 a reference to a mapped task resolves to a lazy sequence of its XComs rather than None. Running under all_done when all upstream tasks are skipped is the documented behaviour of that trigger rule. Airflow 2 reached end of life in April 2026, so we're closing this.