nailo2c opened a new pull request, #52897:
URL: https://github.com/apache/airflow/pull/52897

   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:
   
   ```python
   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](https://github.com/user-attachments/assets/10b6802d-1fb7-4d5d-8dc0-1f67fb80cb92)
   
   Bundle configuration
   ```console
   dag_bundle_config_list = [{"name": "dags-folder", "classpath": 
"airflow.providers.git.bundles.git.GitDagBundle", "kwargs": {"repo_url": 
"g...@github.com:nailo2c/my_repo.git" , "tracking_ref": "main", "subdir": 
"dags"}}]
   ```
   
   Git connection
   ```console
   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](https://github.com/user-attachments/assets/1217be56-f785-4a6a-af67-b8c97e1089da)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to