Skip to content

Tasks with 'none_failed_min_one_success' trigger_rule skipping before Dynamic Task Group is fully expanded #39801

Closed

Description

@gavinhonl

Apache Airflow version

Other Airflow 2 version (please specify below)

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

2.8.3 and 2.9.1

What happened?

If a DAG is run for the first time, a task with a 'none_failed_min_one_success' trigger rule is almost immediately skipped before the dependant upstream tasks are complete resulting in:
image

If I clear the same DAG run, with the process_items task group fully expanded, the DAG completes as expected:
image

What you think should happen instead?

If the a_end task has a 'none_failed_min_one_success' trigger rule it should only be run when its upstream dependant tasks are complete and not in a failed or upstream_failed state and at least one upstream task has succeeded.

How to reproduce

DAG Code:

from datetime import datetime, timedelta

from airflow.decorators import task, task_group
from airflow import DAG, AirflowException
from airflow.operators.empty import EmptyOperator

default_args = {
    'owner': 'insight_techops',
    'depends_on_past': False,
    'start_date': datetime(2019, 1, 1),
    'provide_context': True,
    'retries': 0,
    'retry_delay': timedelta(seconds=30)
}

@task
def parse_csv_schedule():
    items_dict = {'A': '1', 'B': '2', 'C': '3', 'D': '4'}
    return items_dict

@task_group(group_id="process_items")
def process_items(items_dict: dict):
    @task
    def retrieve_item_metadata(items: dict):
        media_asset = items[0]
        print(media_asset)
        return media_asset

    @task_group(group_id="a_process")
    def a_process():
        @task.branch(retries=0)
        def a_start():
            a_handling = 'none'
            if a_handling == 'bypass':
                return "process_items.a_process.a_bypass"
            else:
                return "process_items.a_process.a_end"
            
        a_start = a_start()
        a_bypass = EmptyOperator(task_id='a_bypass')
        a_end = EmptyOperator(task_id='a_end', trigger_rule='none_failed_min_one_success')
        a_start >> a_bypass >> a_end
        a_start >> a_end

    @task
    def mark_item_as_done():
        try:
            print(f"Marking item as Done")
        except Exception as error:
            raise AirflowException(error)
    
    item_dict = retrieve_item_metadata(items=items_dict)
    mark_item_as_done = mark_item_as_done()
    a_process = a_process()
    item_dict >> a_process >> mark_item_as_done

with DAG(dag_id='af055_Debugger', default_args=default_args, max_active_runs=1, schedule_interval=None, tags=['sales']):
    end = EmptyOperator(task_id='end')
    items_dict = parse_csv_schedule()
    items_dict >> process_items.expand(items_dict=items_dict) >> end

I'm pretty sure it is related to the 'none_failed_min_one_success' as if I cause an upstream task within the TaskGroup to fail, the task with the trigger rule in question (and subsequent downstream tasks) are skipped:
image

Compared to if the trigger rule for the a_end is default:
image

Operating System

Mac OS 13.6 and Ubuntu 22.0.4

Versions of Apache Airflow Providers

No response

Deployment

Official Apache Airflow Helm Chart

Deployment details

Dev:
Docker Desktop, Helm, Kubernetes

Prod:
EKS, Helm

Anything else?

100% reproducible

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    kind:bug
    needs-triage
    on May 24, 2024
  2. boring-cyborg commented on May 24, 2024

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

  3. RNHTTR commented on May 25, 2024

    @RNHTTR
    Contributor

    Here's a slightly simpler reproduction without nested task groups or branching:

    from airflow.decorators import dag, task, task_group
    from pendulum import datetime
    
    
    @dag(
        start_date=datetime(2024, 1, 1),
        schedule="@daily",
        catchup=False,
        doc_md=__doc__,
        tags=["example"],
    )
    def repro():
    
        @task
        def init():
            return ["seize", "the", "day"]
    
        @task_group(group_id="tg")
        def tg(message):
            @task
            def imsleepy(message):
                return message
    
            @task(trigger_rule="none_failed_min_one_success")
            def imawake(message):
                print(message)
    
            imawake(imsleepy(message))
    
        tg.expand(message=init())
    
    
    repro()
  4. added and removed
    needs-triage
    on May 25, 2024
  5. mateuslatrova commented on May 31, 2024

    @mateuslatrova
    Contributor

    Hi, could I take this issue?

  6. gavinhonl commented on May 31, 2024

    @gavinhonl
    Author

    Please do. It would be great if you can confirm that you are able to reproduce the issue.

  7. mateuslatrova commented on Jun 1, 2024

    @mateuslatrova
    Contributor

    Please do. It would be great if you can confirm that you are able to reproduce the issue.

    I have just reproduced the issue using @RNHTTR 's example code.

    Does anyone have an idea of which parts of the codebase I should take a look first to find this bug?

    In the meanwhile I will try to figure it out.

  8. RNHTTR commented on Jun 1, 2024

    @RNHTTR
    Contributor

    Please do. It would be great if you can confirm that you are able to reproduce the issue.

    I have just reproduced the issue using @RNHTTR 's example code.

    Does anyone have an idea of which parts of the codebase I should take a look first to find this bug?

    In the meanwhile I will try to figure it out.

    Some candidate starting points:

    One good idea looking into what's going on would be to review the unit tests for none_failed_min_one_success and see the expected behavior.

  9. mateuslatrova commented on Jun 1, 2024

    @mateuslatrova
    Contributor

    Please do. It would be great if you can confirm that you are able to reproduce the issue.

    I have just reproduced the issue using @RNHTTR 's example code.
    Does anyone have an idea of which parts of the codebase I should take a look first to find this bug?
    In the meanwhile I will try to figure it out.

    Some candidate starting points:

    One good idea looking into what's going on would be to review the unit tests for none_failed_min_one_success and see the expected behavior.

    Nice, thank you so much! I will take a look.

  10. le-chartreux commented on Jun 18, 2024

    @le-chartreux
    Contributor

    Hello, I am also facing this issue, it will be awesome if someone can find a solution (or at least a workaround).

    Best regards and thank you for developing Airflow!

  11. 8 remaining items

  12. fredthomsen commented on Dec 20, 2024

    @fredthomsen
    Contributor

    I am observing this same behavior with both TriggerRule.ONE_SUCCESS and TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS on 2.10.3.

  13. olk commented on Jan 31, 2025

    @olk

    I observe a similar behavior in 2.10.4. I filled in a bug report that was unfortunately moved to 'discussion' - #46315.

    The solution I found was to pass the task argument to the joining downstream task (with trigger-policy 'none_failed_min_one_success') - see workaround in #46315.

  14. potiuk commented on Jan 31, 2025

    @potiuk
    Member

    I observe a similar behavior in 2.10.4. I filled in a bug report that was unfortunately moved to 'discussion' - #46315.

    There is nothing wrong in a discussion being a 'diccussion` - main difference is that it is either not clear that this is an airflow isssue and author should likely try to engage otehrs or provide more information to turn it into a clear "issue" or that there are other issues already.

    BTW. Having somethign as "issue" also does not absolutely guarantee that it will be taken care of. It might, or might not be fixed if there is somene who will look at it and decide that they want to spend time on fixing it. That's how open-source development works. And if you are really into fixing a problem, the fastest way to fix it is to contribute a fix, second best is to find someone to do it. Otherwise it's there, waiting for someone to fix it. And the better diagnosed and clear it is, the more likely someone will take a look at it

    Don't mix "issues" here with "service tickets" - things are done here when somene does it. That's it. Issues and discussions just make it easier for those people to show up and fix it, so the more easy it is for them, the better chance they will. But it mostly up to authors to make it easy. Especailly in non-critical issues.

  15. olk commented on Jan 31, 2025

    @olk

    OK, unfortunately I've the impression that nobody takes care about 'discussions' - anyway the 'issue' seams already be addressed in another bug ticket (I've linked each other).

  16. potiuk commented on Jan 31, 2025

    @potiuk
    Member

    OK, unfortunately I've the impression that nobody takes care about 'discussions' - anyway the 'issue' seams already be addressed in another bug ticket (I've linked each other).

    Yes. As I wrote - it's on the author to manage, lead the discusison to something "tangible" - i.e. enough understanding that this is an issue. It's a clear indication that it needs more input and discussions to be seen as "airflow issue" and recognized as such. So it's up to the author (you in this case) to drag atention and involve people to be interested.

    There is no magical "featire" of issue that makes it more popular. there are plenty of issues as well, even if they are seen as classified as issues, they do not have enough traction and they are also often closed automatically, because they have not dragged anyone's attention, so I would not worry too much about "interest", rather "did I, author, do everything to explain and show and drag attention of those who could fix it, to actually pick interest in fixing it" - it's mostly on the author anyway.

    That's how open source development works.

  17. removed their assignment
    on Feb 1, 2025
  18. shahar1 commented on Feb 1, 2025

    @shahar1
    Contributor

    I'm stepping back from the assignement for now due to priorities.
    Anyone is welcome to take this issue. I might reclaim it in the future if no one else does :)

  19. kaisengit commented on Nov 4, 2025

    @kaisengit

    For us, this is a really annoying bug. Since the upgrade to airflow 3 is not that straightforward, does anyone know whether version 3 is also affected?

  20. javaKES commented on Nov 5, 2025

    @javaKES

    For us, this is a really annoying bug. Since the upgrade to airflow 3 is not that straightforward, does anyone know whether version 3 is also affected?

    Did you @kaisengit find any workaround?

  21. added a commit that references this issue on Jul 20, 2026
    abc58e7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    _eol_affected_version:2.9area:corearea:dynamic-task-mappingkind:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions