You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Was previously opened as #72379 (closed to re-open via this form so template labels apply
correctly).
Draft PR with an implementation: #72424 (re-targeted from the previous #72379, closed to re-open via the web form so the template labels applied correctly). 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.
cc @henry3260@guan404ming@dheerajturaga — I see each of you has prior commits in taskinstance.py's failure-handling path, so flagging in case this area is useful for you to weigh in on. cc @potiuk as well, given the listener-registration surface this also touches (same as #36516).
SYED-IRTEZA-HUSSAIN-RIZVI commented on Nov 13, 2026
#72424 is merged: it documents that on_task_instance_failed also fires for an attempt that will be retried, and that listeners can tell the two apart with task_instance.state (UP_FOR_RETRY vs FAILED). As discussed there, a separate hook is not needed, so I am closing this.
Drafted-by: Claude Code (Opus 5.5) (no human review before posting)
Activity
avanish-garg commentedon Sep 2, 2026
Draft PR with an implementation: #72424 (re-targeted from the previous #72379, closed to re-open via the web form so the template labels applied correctly). Went with an additive-only approach (new hook,
on_task_instance_failedleft unchanged) to avoid a breaking change — see the PR description for the reasoning. Happy to rework based on feedback.cc @henry3260 @guan404ming @dheerajturaga — I see each of you has prior commits in
taskinstance.py's failure-handling path, so flagging in case this area is useful for you to weigh in on. cc @potiuk as well, given the listener-registration surface this also touches (same as #36516).SYED-IRTEZA-HUSSAIN-RIZVI commentedon Nov 13, 2026
Hi @avanish-garg , Can I work on this issue ?
avanish-garg commentedon Nov 20, 2026
Thanks for offering. There is already a draft PR for this (#72424); I'm updating it, so I'd suggest picking a different issue to avoid duplicate work.
avanish-garg commentedon Nov 26, 2026
#72424 is merged: it documents that
on_task_instance_failedalso fires for an attempt that will be retried, and that listeners can tell the two apart withtask_instance.state(UP_FOR_RETRYvsFAILED). As discussed there, a separate hook is not needed, so I am closing this.Drafted-by: Claude Code (Opus 5.5) (no human review before posting)