Skip to content

airflow dags test needs dag to be serialized #53682

@kaxil

Description

@kaxil

#50825 re-introduced the bug where we can't run dags.test or airflow dags test command without Serializing DAG to DB manually. This adds huge friction to local dev.

This was originally fixed in 3.0.2 via #50420

Example failure:

root@40de4aa411de:/opt/airflow# airflow dags test a_dag
[2025-07-23T20:19:51.594+0000] {manager.py:122} INFO - DAG bundles loaded: dags-folder, example_dags
[2025-07-23T20:19:51.594+0000] {dagbag.py:620} INFO - Filling up the DagBag from /files/dags/daga.py
Nothing to clear.
/opt/airflow/providers/databricks/src/airflow/providers/databricks/plugins/databricks_workflow.py:44 DeprecationWarning: The `airflow.utils.task_group.TaskGroup` attribute is deprecated. Please use `'airflow.sdk.definitions.taskgroup.TaskGroup'`.
Traceback (most recent call last):
  File "/usr/local/bin/airflow", line 10, in <module>
    sys.exit(main())
  File "/opt/airflow/airflow-core/src/airflow/__main__.py", line 55, in main
    args.func(args)
  File "/opt/airflow/airflow-core/src/airflow/cli/cli_config.py", line 48, in command
    return func(*args, **kwargs)
  File "/opt/airflow/airflow-core/src/airflow/utils/cli.py", line 113, in wrapper
    return f(*args, **kwargs)
  File "/opt/airflow/airflow-core/src/airflow/utils/providers_configuration_loader.py", line 54, in wrapped_function
    return func(*args, **kwargs)
  File "/opt/airflow/airflow-core/src/airflow/utils/session.py", line 100, in wrapper
    return func(*args, session=session, **kwargs)
  File "/opt/airflow/airflow-core/src/airflow/cli/commands/dag_command.py", line 622, in dag_test
    dr: DagRun = dag.test(
  File "/opt/airflow/task-sdk/src/airflow/sdk/definitions/dag.py", line 1113, in test
    dr: DagRun = _get_or_create_dagrun(
  File "/opt/airflow/airflow-core/src/airflow/models/dag.py", line 2326, in _get_or_create_dagrun
    dr = dag.create_dagrun(
  File "/opt/airflow/airflow-core/src/airflow/utils/session.py", line 98, in wrapper
    return func(*args, **kwargs)
  File "/opt/airflow/airflow-core/src/airflow/models/dag.py", line 1581, in create_dagrun
    orm_dagrun = _create_orm_dagrun(
  File "/opt/airflow/airflow-core/src/airflow/utils/session.py", line 98, in wrapper
    return func(*args, **kwargs)
  File "/opt/airflow/airflow-core/src/airflow/models/dag.py", line 249, in _create_orm_dagrun
    raise AirflowException(f"Cannot create DagRun for DAG {dag.dag_id} because the dag is not serialized")
airflow.exceptions.AirflowException: Cannot create DagRun for DAG a_dag because the dag is not serialized

https://github.com/apache/airflow/pull/50825/files#r2226635628

Metadata

Metadata

Assignees

Labels

area:CLIkind:bugThis is a clearly a bugpriority:highHigh priority bug that should be patched quickly but does not require immediate new release

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions