title: Airflow on_failure_callback
body: <p>I have an Airflow DAG with two tasks:</p>
  <ul>
  <li>read_csv</li>
  <li>process_file</li>
  </ul>
  <p>They work fine on their own. I <strong>purposely</strong> created a typo in a pandas Dataframe to learn how <code>on_failure_callback</code> works and to see if it is being triggered. It seems likes from the log that it doesn't:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py&quot;, line 1197, in handle_failure
      task.on_failure_callback(context)
  TypeError: on_failure_callback() takes 0 positional arguments but 1 was given
  </code></pre>
  <p>Why isn't <code>on_failure_callback</code> working?</p>
  <p>Here is a visual representation of the DAG:</p>
  <p><a href="https://i.stack.imgur.com/oXp5E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oXp5E.png" alt="enter image description here" /></a></p>
  <p>Here is the code:</p>
  <pre class="lang-py prettyprint-override"><code>try:
  
      from datetime import timedelta
      from airflow import DAG
      from airflow.operators.python_operator import PythonOperator
      from datetime import datetime
      import pandas as pd
  
      # Setting up Triggers
      from airflow.utils.trigger_rule import TriggerRule
  
      # for Getting Variables from airlfow
      from airflow.models import Variable
  
      print(&quot;All Dag modules are ok ......&quot;)
  except Exception as e:
      print(&quot;Error  {} &quot;.format(e))
  
  
  def read_csv(**context):
      data = [{&quot;name&quot;:&quot;Soumil&quot;,&quot;title&quot;:&quot;Full Stack Software Engineer&quot;}, { &quot;name&quot;:&quot;Nitin&quot;,&quot;title&quot;:&quot;Full Stack Software Engineer&quot;},]
      df = pd.DataFramee(data=data)
  
      dag_config = Variable.get(&quot;VAR1&quot;)
      print(&quot;VAR 1 is : {} &quot;.format(dag_config))
      context['ti'].xcom_push(key='mykey', value=df)
  
  
  def process_file(**context):
      instance = context.get(&quot;ti&quot;).xcom_pull(key='mykey')
      print(instance.head(2))
      return &quot;Process complete &quot;
  
  
  def on_failure_callback(**context):
      print(&quot;Fail works  !  &quot;)
  
  
  
  with DAG(dag_id=&quot;invoices_dag&quot;,
           schedule_interval=&quot;@once&quot;,
           default_args={
               &quot;owner&quot;: &quot;airflow&quot;,
               &quot;start_date&quot;: datetime(2020, 11, 1),
               &quot;retries&quot;: 1,
               &quot;retry_delay&quot;: timedelta(minutes=1),
               'on_failure_callback': on_failure_callback,
           },
           catchup=False) as dag:
  
      read_csv = PythonOperator(
          task_id=&quot;read_csv&quot;,
          python_callable=read_csv,
          op_kwargs={'filename': &quot;Soumil.csv&quot;},
          provide_context=True
      )
  
      process_file = PythonOperator(
          task_id=&quot;process_file&quot;,
          python_callable=process_file,
          provide_context=True
      )
  
  
  
  
  read_csv &gt;&gt; process_file
  
  
  
  
  
  # ====================================Notes====================================
  
  # all_success           -&gt; triggers when all tasks arecomplete
  # one_success           -&gt; trigger when one task is complete
  # all_done              -&gt; Trigger when all Tasks are Done
  # all_failed            -&gt; Trigger when all task Failed
  # one_failed            -&gt; one task is failed
  # none_failed           -&gt; No Task Failed
  
  # ==============================================================================
  
  
  
  # ============================== Executor====================================
  
  # There are Three main  types of executor
  # -&gt; Sequential Executor  run single task in linear fashion wih no parllelism default Dev
  # -&gt; Local Exector  run each task in seperate process
  # -&gt; Celery Executor Run each worker node within multi node architecture Most scalable
  
  # ===========================================================================
  </code></pre>