Airflow "AirflowException ... DAG ... could not be found" in CI
Airflow looked up a DAG by id (to test, trigger, or backfill it) but that id is not in the parsed DagBag. Either the file was not under the dags folder, or it failed to import so the DAG was never registered.
What this error means
A CI step running airflow dags test, airflow tasks test, or a pytest fixture fails with "airflow.exceptions.AirflowException: DAG 'my_dag' could not be found; either it does not exist or it failed to parse".
airflow.exceptions.AirflowException: Dag 'etl_daily' could not be found;
either it does not exist or it failed to parse.Common causes
The DAG file is outside the dags folder
AIRFLOW__CORE__DAGS_FOLDER does not point at the directory holding the DAG in CI, so it is never parsed into the DagBag.
The DAG file failed to import
An exception while importing the module means the DAG object is never created, so the id cannot be found even though the file exists.
How to fix it
Point the dags folder at your repo and list DAGs
- Set the dags folder to your repo path in the CI env.
- Run
airflow dags listto confirm the id is registered. - If it is missing, run
airflow dags list-import-errorsto see the import failure.
export AIRFLOW__CORE__DAGS_FOLDER=$PWD/dags
airflow dags listFix the import error behind the missing DAG
Resolve the exception that stops the module from importing so the DAG registers.
airflow dags list-import-errorsHow to prevent it
- Set DAGS_FOLDER explicitly in CI to your repo dags directory.
- Gate CI on
airflow dags list-import-errorsreturning none. - Keep DAG ids stable and assert them in tests.