Skip to content

Unexpected behavior of dynamically generated task with TriggerRule ONE_FAILED #50210

Description

@jmelot

Apache Airflow version

2.10.5

If "Other Airflow 2 version" selected, which one?

No response

What happened?

We have a dynamically generated task inside a task group with trigger rule ONE_FAILED and an upstream task that fails in some cases and succeeds in others. We find that if one instance of the upstream task fails and others succeed, the task task with trigger rule ONE_FAILED is marked success in all instances rather than being skipped in some and marked success in others.

What you think should happen instead?

I would expect this task to be marked skipped when no upstream task fails.

How to reproduce

I made this simple dag to demonstrate the behavior we are seeing

import logging

from airflow.decorators import task, task_group
from airflow.decorators import dag
from airflow.utils.trigger_rule import TriggerRule


logger = logging.getLogger(__name__)

@task
def divide(i):
    return 30/i

@task(trigger_rule=TriggerRule.ONE_FAILED)
def report_failure(i):
    logger.info(f"{i} failed")

@task
def report_success(i):
    logger.info(f"{i} succeeded")

@dag(
    dag_id="Test-Trigger-Rule",
    schedule=None,
    catchup=False,
)
def test_trigger_rule_dag():
    @task
    def gen_examples():
        return [0,1,2,3]
    
    @task_group
    def divide_and_report(i):
        divide(i) >> [report_success(i), report_failure(i)]
        
    divide_and_report.expand(i=gen_examples())

test_trigger_rule_dag()

When I run this dag, report_success behaves as I would expect, with three mapped tasks in success and one in upstream_failed. report_failure is always marked success, however, rather than three tasks being marked skipped and one success.

Image Image

If this is a bug I'm happy to do what I can to help fix it. If I've misunderstood something and this behavior is actually expected, I'm happy to help update documentation if needed so others aren't confused.

Operating System

macOS 15.4.1

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions