eladkal commented on code in PR #49270:
URL: https://github.com/apache/airflow/pull/49270#discussion_r2043752197
##########
providers/git/src/airflow/providers/git/bundles/git.py:
##########
@@ -79,16 +80,20 @@ def __init__(
)
self._log.debug("bundle configured")
- try:
- self.hook = GitHook(git_conn_id=self.git_conn_id,
repo_url=self.repo_url)
- self.repo_url = self.hook.repo_url
- self._log.debug("repo_url updated from hook",
repo_url=self.repo_url)
- except AirflowException as e:
- self._log.warning("Could not create GitHook",
conn_id=self.git_conn_id, exc=e)
+ self.hook: GitHook | None = None
+ if self.git_conn_id:
+ try:
+ self.hook = GitHook(git_conn_id=self.git_conn_id,
repo_url=self.repo_url)
+ except AirflowException as e:
+ self._log.warning("Could not create GitHook",
conn_id=self.git_conn_id, exc=e)
+ else:
+ self.repo_url = self.hook.repo_url
+ self._log.debug("repo_url updated from hook",
repo_url=self.repo_url)
Review Comment:
I think we should not accept cases of both repo_url and git_conn_id.
From what I understand the repo_url means that we ignore the git_conn_id.
So both parameters should be mutually exclusive
Similar to:
https://github.com/apache/airflow/blob/243fe86d4b3e59bb12977b3e36ca3f2ed27ca0f8/airflow-core/src/airflow/secrets/local_filesystem.py#L203-L207
This is important because consider a case where user provided both, then
someone went to Connection->Git and changed the connection name. This code will
automatically change to use the `repo_url` possibly without intention to do so
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]