You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "amoghrajesh (via GitHub)" <gi...@apache.org> on 2025/12/05 08:46:58 UTC
[PR] Fix misleading error message when GitHook creation fails [airflow]
amoghrajesh opened a new pull request, #59084:
URL: https://github.com/apache/airflow/pull/59084
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
Previously, when GitHook creation failed (take for example a simple case of git connection not found), the exception was caught and suppressed, allowing bundle initialization to proceed in a way, which was a facade. This led to a misleading error message later: `"Connection {conn_id} doesn't have a host url"` instead of the actual error.
I am making this change to ensure that exceptions propagate immediately during bundle creation with clear error messages. The DAG processor handles exceptions per-bundle, so one failing bundle doesn't prevent others from loading successfully.
For testing, use a config like this where git connection doesnt exist:
```shell script
export AIRFLOW__DAG_PROCESSOR__DAG_BUNDLE_CONFIG_LIST='[
{
"name": "test-git-bundle",
"classpath": "airflow.providers.git.bundles.git.GitDagBundle",
"kwargs": {
"tracking_ref": "main",
"git_conn_id": "non_existent_connection"
}
},
{
"name": "local-bundle",
"classpath": "airflow.dag_processing.bundles.local.LocalDagBundle",
"kwargs": {
"path": "/Users/amoghdesai/Documents/OSS/repos/airflow/files/test_dags",
"refresh_interval": 0
}
}
]'
```
Before it looked like this:
```python
2025-12-05T07:18:54.567663Z [error ] Error initializing bundle test-git-bundle: Connection non_existent_connection doesn't have a host url [airflow.dag_processing.manager.DagFileProcessorManager] loc=manager.py:528
Traceback (most recent call last):
File "/opt/airflow/airflow-core/src/airflow/dag_processing/manager.py", line 526, in _refresh_dag_bundles
bundle.initialize()
File "/opt/airflow/providers/git/src/airflow/providers/git/bundles/git.py", line 134, in initialize
raise AirflowException(f"Connection {self.git_conn_id} doesn't have a host url")
airflow.sdk.exceptions.AirflowException: Connection non_existent_connection doesn't have a host url
2025-12-05T07:18:59.647017Z [error ] Error initializing bundle test-git-bundle: Connection non_existent_connection doesn't have a host url [airflow.dag_processing.manager.DagFileProcessorManager] loc=manager.py:528
Traceback (most recent call last):
File "/opt/airflow/airflow-core/src/airflow/dag_processing/manager.py", line 526, in _refresh_dag_bundles
bundle.initialize()
File "/opt/airflow/providers/git/src/airflow/providers/git/bundles/git.py", line 134, in initialize
raise AirflowException(f"Connection {self.git_conn_id} doesn't have a host url")
airflow.sdk.exceptions.AirflowException: Connection non_existent_connection doesn't have a host url
```
Now it looks like this:
```python
root@c435d9bb0884:/opt/airflow# airflow dag-processor
2025-12-05T08:45:11.600794Z [warning ] Failed to convert value. Please check memray_trace_components key in profiling section. it must be one of scheduler, dag_processor, api, if not the value is ignored [airflow._shared.configuration.parser] loc=parser.py:1127
__file__='/files/plugins/triggera.py' loaded
__file__='/files/plugins/triggera_comprehensive.py' loaded
2025-12-05T08:45:12.101992Z [info ] Starting the Dag Processor Job [airflow.jobs.dag_processor_job_runner.DagProcessorJobRunner] loc=dag_processor_job_runner.py:59
2025-12-05T08:45:12.102262Z [info ] Processing files using up to 2 processes at a time [airflow.dag_processing.manager.DagFileProcessorManager] loc=manager.py:266
2025-12-05T08:45:12.102305Z [info ] Process each file at most once every 30 seconds [airflow.dag_processing.manager.DagFileProcessorManager] loc=manager.py:267
2025-12-05T08:45:12.168422Z [info ] DAG bundles loaded: test-git-bundle, local-bundle [airflow.dag_processing.bundles.manager.DagBundlesManager] loc=manager.py:209
2025-12-05T08:45:12.174930Z [error ] Could not create GitHook [airflow.providers.git.bundles.git] bare_repo_path=PosixPath('/tmp/airflow/dag_bundles/test-git-bundle/bare') bundle_name=test-git-bundle conn_id=non_existent_connection exc=AirflowNotFoundException("The conn_id `non_existent_connection` isn't defined") git_conn_id=non_existent_connection loc=git.py:94 repo_path=PosixPath('/tmp/airflow/dag_bundles/test-git-bundle/tracking_repo') version=None versions_path=PosixPath('/tmp/airflow/dag_bundles/test-git-bundle/versions')
Traceback (most recent call last):
File "/opt/airflow/providers/git/src/airflow/providers/git/bundles/git.py", line 92, in __init__
self.hook = GitHook(git_conn_id=git_conn_id or "git_default", repo_url=self.repo_url)
File "/opt/airflow/providers/git/src/airflow/providers/git/hooks/git.py", line 69, in __init__
connection = self.get_connection(git_conn_id)
File "/opt/airflow/task-sdk/src/airflow/sdk/bases/hook.py", line 61, in get_connection
conn = Connection.get(conn_id)
File "/opt/airflow/task-sdk/src/airflow/sdk/definitions/connection.py", line 224, in get
return _get_connection(conn_id)
File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/context.py", line 176, in _get_connection
raise AirflowNotFoundException(f"The conn_id `{conn_id}` isn't defined")
airflow.sdk.exceptions.AirflowNotFoundException: The conn_id `non_existent_connection` isn't defined
2025-12-05T08:45:12.175495Z [error ] Error creating bundle 'test-git-bundle': The conn_id `non_existent_connection` isn't defined [airflow.dag_processing.bundles.manager.DagBundlesManager] loc=manager.py:249
Traceback (most recent call last):
File "/opt/airflow/airflow-core/src/airflow/dag_processing/bundles/manager.py", line 247, in sync_bundles_to_db
new_template, new_params = _extract_and_sign_template(name)
File "/opt/airflow/airflow-core/src/airflow/dag_processing/bundles/manager.py", line 216, in _extract_and_sign_template
bundle_instance = self.get_bundle(name)
File "/opt/airflow/airflow-core/src/airflow/dag_processing/bundles/manager.py", line 337, in get_bundle
return cfg_bundle.bundle_class(name=name, version=version, **cfg_bundle.kwargs)
File "/opt/airflow/providers/git/src/airflow/providers/git/bundles/git.py", line 92, in __init__
self.hook = GitHook(git_conn_id=git_conn_id or "git_default", repo_url=self.repo_url)
File "/opt/airflow/providers/git/src/airflow/providers/git/hooks/git.py", line 69, in __init__
connection = self.get_connection(git_conn_id)
File "/opt/airflow/task-sdk/src/airflow/sdk/bases/hook.py", line 61, in get_connection
conn = Connection.get(conn_id)
File "/opt/airflow/task-sdk/src/airflow/sdk/definitions/connection.py", line 224, in get
return _get_connection(conn_id)
File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/context.py", line 176, in _get_connection
raise AirflowNotFoundException(f"The conn_id `{conn_id}` isn't defined")
airflow.sdk.exceptions.AirflowNotFoundException: The conn_id `non_existent_connection` isn't defined
2025-12-05T08:45:12.175815Z [warning ] Removing ownership of team 'None' from Dag bundle 'local-bundle' [airflow.dag_processing.bundles.manager.DagBundlesManager] loc=manager.py:28
```
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix misleading error message when GitHook creation fails [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #59084:
URL: https://github.com/apache/airflow/pull/59084#issuecomment-3627371271
Oh this one will need manual port over.
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix misleading error message when GitHook creation fails [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #59084:
URL: https://github.com/apache/airflow/pull/59084#issuecomment-3627361353
Ahhh missed the v3 label!
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix misleading error message when GitHook creation fails [airflow]
Posted by "dstandish (via GitHub)" <gi...@apache.org>.
dstandish commented on code in PR #59084:
URL: https://github.com/apache/airflow/pull/59084#discussion_r2593338620
##########
providers/git/src/airflow/providers/git/bundles/git.py:
##########
@@ -91,7 +91,9 @@ def __init__(
try:
self.hook = GitHook(git_conn_id=git_conn_id or "git_default", repo_url=self.repo_url)
except Exception as e:
- self._log.warning("Could not create GitHook", conn_id=git_conn_id, exc=e)
+ self._log.exception("Could not create GitHook", conn_id=git_conn_id, exc=e)
+ # re raise so exception propagates immediately with clear error message
+ raise
Review Comment:
do we need to log the exception given that it will raise anyway? probably not i'd think
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix misleading error message when GitHook creation fails [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #59084:
URL: https://github.com/apache/airflow/pull/59084#discussion_r2597369875
##########
providers/git/src/airflow/providers/git/bundles/git.py:
##########
@@ -91,7 +91,9 @@ def __init__(
try:
self.hook = GitHook(git_conn_id=git_conn_id or "git_default", repo_url=self.repo_url)
except Exception as e:
- self._log.warning("Could not create GitHook", conn_id=git_conn_id, exc=e)
+ self._log.exception("Could not create GitHook", conn_id=git_conn_id, exc=e)
+ # re raise so exception propagates immediately with clear error message
+ raise
Review Comment:
Right, its just noise. Removed it
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix misleading error message when GitHook creation fails [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh merged PR #59084:
URL: https://github.com/apache/airflow/pull/59084
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix misleading error message when GitHook creation fails [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #59084:
URL: https://github.com/apache/airflow/pull/59084#issuecomment-3626841624
Sorry for the spam folks, possibly due to a bad rebase I had!
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix misleading error message when GitHook creation fails [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #59084:
URL: https://github.com/apache/airflow/pull/59084#issuecomment-3631704146
Manual port to v3 branch here: https://github.com/apache/airflow/pull/59236
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org