hkc-8010 opened a new pull request, #69821: URL: https://github.com/apache/airflow/pull/69821
## Summary When a deferrable operator's trigger yields a terminal `TaskFailedEvent`, the task was always marked `failed` and its `on_failure_callback` ran, even when the task still had retries remaining. A worker-side failure with retries left instead goes `up_for_retry` and runs `on_retry_callback`. This makes trigger-driven failures behave the same way. The `BaseTaskEndEvent` handler in `airflow-core/src/airflow/models/trigger.py` now, for a `FAILED` event, loads the serialized task and routes through `TaskInstance.handle_failure()`, the same path the scheduler executor-event handling has used since #56586. `handle_failure` sets `up_for_retry` or `failed` based on retry-eligibility and fires the `on_task_instance_failed` listener, failure metrics, and a Log entry. The callback request now carries the resolved `task_callback_type` so the DAG processor runs `on_retry_callback` vs `on_failure_callback` correctly. `TaskSuccessEvent` and `TaskSkippedEvent` are unchanged. closes: #69819 ## Changes - `airflow-core/src/airflow/models/trigger.py`: route trigger-emitted failures through `handle_failure`, thread the retry-aware `task_callback_type` into the callback, and skip the xcom push on the retry path. - `airflow-core/tests/unit/models/test_trigger.py`: new parametrized test covering the retry-eligible case (`up_for_retry` + `on_retry_callback` + `on_task_instance_failed` listener) and the exhausted case (`failed` + `on_failure_callback`); the existing end-event test now sets a realistic `start_date` (a deferred task has already run). - `airflow-core/newsfragments/69819.bugfix.rst`. ## Testing - `pytest airflow-core/tests/unit/models/test_trigger.py` (39 passed). - Confirmed the new test fails on `main` (the task stays `failed` and the callback is routed as a failure) and passes with this change. ## PR Checklist - [x] My PR is targeted at the `main` branch - [x] Tests added - [x] Newsfragment added under `airflow-core/newsfragments/` - [x] `prek` hooks pass This change was written with AI assistance (Claude); the author reviewed the diff and reproduction. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
