You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ABiscuitttt (via GitHub)" <gi...@apache.org> on 2026/07/27 08:49:27 UTC
[PR] Fire failure listeners when TriggerDagRunOperator API call fails [airflow]
ABiscuitttt opened a new pull request, #70506:
URL: https://github.com/apache/airflow/pull/70506
When `TriggerDagRunOperator` targets a nonexistent Dag (or the API server otherwise rejects the trigger with 403/5xx), the supervisor reports the error by raising `AirflowRuntimeError` from the `TriggerDagRun` comms round-trip. That raise happens inside `run()`'s `except DagRunTriggerException` handler, and an exception raised in an except handler is not caught by the sibling except clauses — it escaped `run()` entirely. `main()` then never reached `finalize()`, the only place `on_task_instance_failed` / `on_failure_callback` listeners run. The task still showed FAILED in the UI (via the supervisor's exit-code fallback), but alerting plugins were silently skipped for exactly this failure mode.
The fix routes the error through the normal failure path (`_handle_current_task_failed`), so the task returns a terminal state, `finalize()` fires the listeners, and retry policy is honored (`UP_FOR_RETRY` when retries remain).
Regression tests cover both the no-retry (`FAILED`) and retry (`UP_FOR_RETRY`) paths, asserting the terminal state reaches the supervisor instead of the error escaping `run()`.
closes: #63089
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Kimi Code CLI
Generated-by: Kimi Code CLI following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fire failure listeners when TriggerDagRunOperator API call fails [airflow]
Posted by "ABiscuitttt (via GitHub)" <gi...@apache.org>.
ABiscuitttt commented on PR #70506:
URL: https://github.com/apache/airflow/pull/70506#issuecomment-5216219305
Closing as superseded by #70719, which addresses the same `TriggerDagRunOperator` 404 failure-listener issue more generally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fire failure listeners when TriggerDagRunOperator API call fails [airflow]
Posted by "ABiscuitttt (via GitHub)" <gi...@apache.org>.
ABiscuitttt closed pull request #70506: Fire failure listeners when TriggerDagRunOperator API call fails
URL: https://github.com/apache/airflow/pull/70506
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fire failure listeners when TriggerDagRunOperator API call fails [airflow]
Posted by "ABiscuitttt (via GitHub)" <gi...@apache.org>.
ABiscuitttt commented on PR #70506:
URL: https://github.com/apache/airflow/pull/70506#issuecomment-5099076544
Some context on how we ran into this: we run a global failure-alert listener plugin that pages our on-call channel (Feishu/Lark) through the `on_task_instance_failed` hook when a task instance reaches its final `FAILED` state:
```python
@hookimpl
def on_task_instance_failed(previous_state, task_instance, error):
if task_instance.state != TaskInstanceState.FAILED:
return # still up_for_retry; only alert on final failure
send_alert(task_instance, error) # internal notification
```
(Internal plugin code sanitized for posting.)
When a `TriggerDagRunOperator` points at a non-existent Dag, the task dies from the API error without this hook ever firing, so no alert goes out — from the on-call perspective the task fails silently. That is what led to this fix: routing the API error through the normal failure path makes `finalize()` fire the listener (and honor the retry policy) as expected.
---
Drafted-by: Kimi Code CLI (no human review before posting)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org