GitHub user pskrobich created a discussion: Issue with on_failure_callback on
task level
Hello,
I'm experiencing an issue where the on_failure_callback is not executing when
configured at the task level via default_args, while the on_success_callback
works correctly.
**Current DAG Configuration:**
```
@dag(
schedule='*/20 * * * *',
default_args={
'on_failure_callback': slack_notification_callback,
'on_success_callback': slack_notification_callback
},
)
```
**Problem:**
- Success callbacks trigger correctly after each task completion and send Slack
notifications
- Failure callbacks do not trigger at all when tasks fail
- Both callbacks use the same function (slack_notification_callback) for Slack
notifications
I specifically need task-level callbacks rather than DAG-level callbacks
because with DAG-level callbacks, I cannot identify which specific task failed,
making it difficult to provide meaningful failure notifications.
```
@dag(
schedule='*/20 * * * *',
on_failure_callback= slack_notification_callback,
on_success_callback= slack_notification_callback
)
```
Is this a known issue with task-level failure callbacks in default_args? Are
there any workarounds to ensure failure callbacks execute at the task level
while maintaining access to task-specific information?
GitHub link: https://github.com/apache/airflow/discussions/55987
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]