Skip to content

GitDagBundle: DAG processor fails to load versioned DAGs due to missing materialized folders #52040

@liyude-tw

Description

@liyude-tw

Apache Airflow Provider(s)

git

Versions of Apache Airflow Providers

No response

Apache Airflow version

3.0.2

Operating System

Ubuntu 20.04.6 LTS

Deployment

Virtualenv installation

Deployment details

No response

What happened

When using GitDagBundle with supports_versioning=True, Airflow DAG Processor fails to execute DAG callbacks because it cannot find the materialized code under versions/<commit_hash>/.

Only the tracking_repo/ folder is updated with the latest version, but when a DAG-level callback (e.g. on_success_callback, on_failure_callback) is triggered, the callback request sent to the DAG Processor points to the versioned folder (e.g. /dag-bundles/git_xxx/versions/<commit_hash>/dag.py), which does not exist by default.

This leads to a failure in the DAG Processor when trying to load the DAG from the file. Specifically, inside DagFileProcessor._execute_dag_callbacks, the following code fails:
dag = dagbag.dags[request.dag_id] # returns empty

This happens because dagbag.process_file() cannot find the DAG file at the specified path (versions/<commit_hash>/...), and so the DAG is never loaded, and the callback is silently skipped.

What you think should happen instead

The DAG Processor should also materialize the correct version of the DAG source code (i.e., clone the Git repository to the appropriate versions/<commit_hash> path) before attempting to load and execute DAG-level callbacks.

How to reproduce

  1. Use GitDagBundle with supports_versioning=True.
  2. Define a DAG-level on_failure_callback or on_success_callback.
  3. Deploy a new Git version and trigger a DAG run that invokes the callback.
  4. The DAG tasks execute successfully.
  5. But DAG callback fails because the path in the callback request is under versions/<commit_hash>/, which is not materialized
  6. As a workaround, we patched GitDagBundle.refresh() to also clone the repo into the versions/ directory.

Anything else

In our environment, DAGs are triggered via Asset, but this should not affect the behavior.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions