Skip to content

Listener hook can't distinguish a task auto-retrying from a terminal failure #72379

Closed

Description

@avanish-garg

Description

on_task_instance_failed fires identically whether a task instance is about to be automatically
retried (state set to UP_FOR_RETRY) or has permanently failed (state set to FAILED). The hook
call in models/taskinstance.py sits after the retry-eligibility branch and fires unconditionally
either way, using the same hook name.

Use case/motivation

This makes the listener API noisy for a common use case: an alerting/paging integration built on
on_task_instance_failed gets triggered on every transient retry of a flaky task, not just the
final terminal failure, which undermines the signal-to-noise of building alerting on this hook.

Airflow's listener spec already carves out sub-outcomes this way elsewhere —
on_task_instance_skipped exists specifically to distinguish "skipped" from the generic
success/failure buckets. Same pattern fits here: a new on_task_instance_up_for_retry hookspec,
fired when a task instance is set to UP_FOR_RETRY, additive alongside the existing
on_task_instance_failed (left unchanged, to avoid a breaking change for existing listeners).

Related issues

None found.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Draft PR open: #72424.

Code of Conduct

Activity

  1. boring-cyborg commented on Sep 1, 2026

    @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.

  2. avanish-garg commented on Sep 2, 2026

    @avanish-garg
    ContributorAuthor

    Opened a draft PR with an implementation: #72424. Went with an additive-only approach (new hook, on_task_instance_failed left unchanged) to avoid a breaking change — see the PR description for the reasoning. Happy to rework based on feedback.

  3. avanish-garg commented on Sep 2, 2026

    @avanish-garg
    ContributorAuthor

    Closing to re-open this via GitHub's web form instead of the API, so the feature-request template's labels (kind:feature, needs-triage) get applied automatically — that only happens through the actual form, not gh issue create. Will link the new issue number here and re-target the open draft PR (#72424) to it.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions