GitHub user mbarugelCA added a comment to the discussion: DAG callback `context` does not have `dag_run` set in Airflow 3 but it is set in Airflow 2.
I am having a similar issue too. I used `context["dag_run"].task_instances` within `on_failure_callback` to report some stats (e.g., list the failed tasks). I also used DagRun.find() to report additional stats on failure, such as how often the DAG has failed over the past X days. The recommended pattern now is to use the REST API? Does this mean I need to set up API auth to get access to this info? Additionally, does that mean I need to have the API server running to run `airflow dags test my_dag` and access the DagRun info? Looking at the available methods in the objects, I found that the DagRun is still accessible with the following code. ``` dag_run = context["dag"].fetch_dagrun(context["dag"].safe_dag_id, context["run_id"]) tis = dag_run.get_task_instances() ``` Is this pattern OK to use, or is it expected to go away in future releases of Airflow 3? GitHub link: https://github.com/apache/airflow/discussions/53618#discussioncomment-14026340 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
