Skip to content

ALL_DONE trigger rule not respected in TaskFlow API for upstream failures #23942

Closed

Description

@ZouhirSarrar

Apache Airflow version

2.3.0

What happened

Hello!

I'm using taskflow api for my dag and was trying to run the last task even if the previous task failed, I used @task(trigger_rule=TriggerRule.ALL_DONE) but i still got the ending task failed too.

image

The UI confirms that I declared the trigger_rule "all_done"
image

What you think should happen instead

No response

How to reproduce

This is the whole code

import logging
import pendulum
from airflow.decorators import task, dag
from airflow.utils.trigger_rule import TriggerRule


@dag(
    schedule_interval=None,
    start_date=pendulum.datetime(2021, 5, 10, tz="UTC"),
    catchup=False,
)
def taskflow_trigger():
    @task()
    def first_task():
        return "first_task"

    @task
    def second_task(value):
        return "second_task"

    @task
    def task_to_fail(value):
        data = {"test": 1}
        val = data["not_here"]
        return val

    @task(trigger_rule=TriggerRule.ALL_DONE)
    def end(value):

        return "yes"

    op_1 = first_task()
    op_3 = task_to_fail(op_1)
    op_2 = second_task(op_1)
    end([op_3, op_2])

taskflow_trigger = taskflow_trigger()

Operating System

"Debian GNU/Linux 11 (bullseye)

Versions of Apache Airflow Providers

No response

Deployment

Docker-Compose

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

  1. boring-cyborg commented on May 26, 2022

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template!

  2. josh-fell commented on May 26, 2022

    @josh-fell
    Contributor

    IMO this should be expected. The end task is expecting an input from the task_to_fail output but the latter task has failed and doesn't produce an XComArg. The end task does actually run so the trigger rule is respected, but fails with:

    airflow.exceptions.AirflowException: XComArg result from task_to_fail at taskflow_trigger with key="return_value" is not found!

    What would you like the behavior to be in this scenario?

  3. ZouhirSarrar commented on May 26, 2022

    @ZouhirSarrar
    Author

    i want the end task to continue working

  4. changed the title [-]Trigger_rule don't work while using task decorator[/-] [+]`ALL_DONE` trigger rule not respected in TaskFlow API[/+] on Jun 13, 2022
  5. changed the title [-]`ALL_DONE` trigger rule not respected in TaskFlow API[/-] [+]`ALL_DONE` trigger rule not respected in TaskFlow API for upstream failures[/+] on Jun 13, 2022
  6. josh-fell commented on Jun 13, 2022

    @josh-fell
    Contributor

    A similar issue was raised when upstream tasks are skipped. The point of "the downstream should not run if any of its depended upstream XCom values fail to resolve" (in this comment) was brought up again.

    @uranusjr curious for your take on this issue generally.

    I feel that, as this issue is written, the consensus is that a downstream TaskFlow task should not execute if a dependent, upstream XCom cannot be found.

  7. uranusjr commented on Jun 14, 2022

    @uranusjr
    Member

    Since an XCom push can never be None1, we can probably just set the value to None in this case. Combining this with #24401, we probably need to do some additional checks in XComArg.resolve() to take account the current task’s trigger rule, and resolve to None when appropriate.

    Footnotes

    1. A design decision I didn’t agree with but that ship sailed long ago. ↩

  8. ashb commented on Jul 6, 2022

    @ashb
    Member

    Duplicate of #24338 (It's the same underlying cause)

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions