You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "gabrielboehme (via GitHub)" <gi...@apache.org> on 2023/08/11 16:58:22 UTC

[GitHub] [airflow] gabrielboehme commented on issue #26760: DAG on_failure_callback uses wrong context

gabrielboehme commented on issue #26760:
URL: https://github.com/apache/airflow/issues/26760#issuecomment-1675096321

   @viniciusdsmello I have encountered the same problem as you. I have the following dag which sends a Slack notification. In my case, task_1 throws an error, but the given context to the callback function is for task_2.
   
   `def slack_alert(context):
       slack_msg = \
           f"""
               :x: Task Failed.
   ]            *Task*: {context.get('task_instance').task_id}
               *Dag*: {context.get('task_instance').dag_id}
               *Execution Time*: {context.get('execution_date')}
               <{context.get('task_instance').log_url}|*Logs*>
           """
       slk = SlackHelper()
       slk.send_message_to_channel(
           channel="#random_channel",
           text=slack_msg
       )`


-- 
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