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
AirflowException, this will cause the task to move immediately to failure state.
from airflow import AirflowException
ValueError can be used for fail and retry.