IvanildoBarauna opened a new pull request, #64198:
URL: https://github.com/apache/airflow/pull/64198
When `AirflowFailException` was raised inside `on_retry_callback`, it was
silently swallowed by the generic `except Exception` handler in
`_run_task_state_change_callbacks`, causing the task to proceed with retry as
normal — ignoring the explicit intent to fail without retry.
### Changes
- **`_run_task_state_change_callbacks`**: added `except
AirflowFailException: raise` before the generic `except Exception`, so
`AirflowFailException` propagates out of callbacks.
- **`run()` / `finally`**: `RetryTask` is no longer sent to the supervisor
when `state == UP_FOR_RETRY` — the decision is deferred to `finalize()`.
- **`finalize()`**: captures `AirflowFailException` from
`on_retry_callback`. When caught:
- Changes state to `FAILED`
- Sends `TaskState(FAILED)` to the supervisor (instead of `RetryTask`)
- Runs `on_failure_callback`
- Sends failure email notification (if configured)
- In the normal (no exception) path, sends `RetryTask` as before.
- **New test**
`test_airflow_fail_exception_in_on_retry_callback_marks_task_as_failed`
validates the full behavior.
closes: #60172
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Sonnet 4.6
Generated-by: Claude Sonnet 4.6 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]