Skip to content

Conversation

@nailo2c
Copy link
Contributor

@nailo2c nailo2c commented Jul 4, 2025

Closes: #52332

Why

A corner case in GitDagBundle causes pulling DAGs from a private GitHub repository to fail whenever repo_url is set in dag_bundle_config_list.

How

Move the try / except block before the repo_url detection so that the GitHook is always created.

What

I tested with a private repo and created an example DAG:

from datetime import datetime, timedelta

from airflow import DAG
from airflow.operators.bash import BashOperator

default_args = {
    "owner": "airflow",
    "depends_on_past": False,
    "retries": 1,
    "retry_delay": timedelta(minutes=5),
}

with DAG(
    dag_id="hello_airflow",
    default_args=default_args,
    description="A simple hello-world DAG",
    schedule="0 0 * * *",
    start_date=datetime(2025, 7, 4),
    catchup=False,
    tags=["example"],
) as dag:

    say_hello = BashOperator(
        task_id="say_hello",
        bash_command='echo "Hello Airflow!"',
    )

截圖 2025-07-04 下午4 14 25

Bundle configuration

dag_bundle_config_list = [{"name": "dags-folder", "classpath": "airflow.providers.git.bundles.git.GitDagBundle", "kwargs": {"repo_url": "git@github.com:nailo2c/my_repo.git" , "tracking_ref": "main", "subdir": "dags"}}]

Git connection

airflow connections add git_default \
  --conn-json '{
    "conn_type": "git",
    "login": "git",
    "host": "github.com",
    "extra": {
      "private_key": "*****",
      "strict_host_key_checking": "no"
    }
  }'

It works well
截圖 2025-07-04 下午4 14 08

@potiuk
Copy link
Member

potiuk commented Jul 13, 2025

Can you please add tests for it ? It seems super-suspicious to see tests passing both before and after the change - which basically means that it's not tested.

@nailo2c
Copy link
Contributor Author

nailo2c commented Jul 13, 2025

You're right, I should add a test for it, even though it's a small logic change. I'll be more mindful about this in future contributions. Thanks for the reminder! Let me add a test for it :)

@nailo2c
Copy link
Contributor Author

nailo2c commented Jul 14, 2025

Done, this test fails on the main branch but passes with this PR. The test supplies a repo_url when constructing GitDagBundle. On main branch, the presence of repo_url prevents GitHook from being instantiated, reproducing the original bug.

@potiuk potiuk merged commit 72cfa64 into apache:main Jul 18, 2025
102 checks passed
@potiuk
Copy link
Member

potiuk commented Jul 18, 2025

You're right, I should add a test for it, even though it's a small logic change. I'll be more mindful about this in future contributions. Thanks for the reminder! Let me add a test for it :)

Thanks - yeah. No matter how small logic - we should test it :)

karenbraganz pushed a commit to karenbraganz/airflow that referenced this pull request Jul 18, 2025
…2897)

* fix: always create GitHook even when `repo_url` is provided

* add a test for the init of GitDagBundle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repo URLs provided in the git bundle config prevent git hooks executing

2 participants