Skip to content

Deferrable task that ends via TaskFailedEvent ignores retries and always runs on_failure_callback #69819

Closed

Description

@hkc-8010

What happened

When a deferrable operator's trigger yields a terminal TaskFailedEvent (a BaseTaskEndEvent with task_instance_state=FAILED) to fail a task without resuming it on a worker, the task is always marked failed terminally and its on_failure_callback runs, even when the task still has retries remaining.

A task that fails while running on a worker with retries left goes to up_for_retry and runs on_retry_callback. A task that fails through its trigger does not. Deferrable tasks that fail via the trigger silently lose their retries and emit a false on_failure_callback.

What you think should happen instead

A trigger-emitted failure should respect the task's retry configuration, the same way a worker-side failure does: if the task is eligible to retry, go up_for_retry and run on_retry_callback; only when retries are exhausted, fail terminally and run on_failure_callback.

How to reproduce

Defer a task with retries=1 whose trigger yields TaskFailedEvent(). It goes straight to failed and on_failure_callback fires on the first attempt, instead of retrying.

The cause is the BaseTaskEndEvent handler in airflow-core/src/airflow/models/trigger.py, which calls set_state(event.task_instance_state) and sends the callback with task_callback_type=event.task_instance_state without any retry-eligibility check.

Context

The scheduler executor-event path already routes by retry-eligibility (#56586) and the DAG processor honors task_callback_type (UP_FOR_RETRY -> on_retry_callback). The trigger end-event path was not updated to match.

Are you willing to submit a PR?

Yes

Activity

  1. added
    kind:bug
    on Jul 13, 2026
  2. added a commit that references this issue on Jul 13, 2026
    5dfb1ce
  3. added 3 commits that reference this issue on Aug 5, 2026
    dd1f84a
    7aee7d6
    03b0f96
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

    area:corekind:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions