How do I force a task on airflow to fail? How do I force a task on airflow to fail? python python

How do I force a task on airflow to fail?


raise exception when you meet the error condition ( in your case: when file is not sucesfully parsed)

raise ValueError('File not parsed completely/correctly')

raise relevant error type with suitable message


Yes, raise AirflowException, this will cause the task to move immediately to failure state.

from airflow import AirflowException

ValueError can be used for fail and retry.


AirflowFailException is now available to make the task fail without retries