fix(providers/git): force HTTP auth for public repos via extraHeader#63471
Open
antonio-mello-ai wants to merge 1 commit intoapache:mainfrom
Open
fix(providers/git): force HTTP auth for public repos via extraHeader#63471antonio-mello-ai wants to merge 1 commit intoapache:mainfrom
antonio-mello-ai wants to merge 1 commit intoapache:mainfrom
Conversation
01462cc to
0a5faf1
Compare
86c308c to
7e95167
Compare
Git does not send credentials for public repositories because the server never responds with 401. This causes authenticated rate limits to be ignored even when valid credentials are configured. Add http.extraHeader with Basic auth via GIT_CONFIG_* env vars (git >= 2.31) so credentials are sent on every request. Also update _fetch_bare_repo to pass all hook env vars (not just GIT_SSH_COMMAND). Closes apache#54829 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7e95167 to
30f945e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Git does not send credentials for public repositories because the server never responds with a 401 challenge. This causes Airflow's DAG bundle git fetches to hit anonymous rate limits even when valid credentials are configured in the connection.
Root cause
Git's HTTPS behavior: it always tries anonymous access first and only sends credentials if the server responds with 401. Public repos don't issue 401, so credentials embedded in the URL are never sent.
Fix
When an HTTP/HTTPS connection has an
auth_token, setGIT_CONFIG_*environment variables to inject anhttp.extraHeaderwith aBasicauth token:This forces git to send the
Authorizationheader on every request (git >= 2.31), allowing authenticated rate limits to apply even for public repositories.Also updated
_fetch_bare_repoinGitDagBundleto pass all hook env vars viacustom_environment(**self.hook.env)instead of onlyGIT_SSH_COMMAND. This ensures the auth header is used during both clone and fetch operations.Changes
GitHook._set_http_auth_env(): New method that encodes credentials and setsGIT_CONFIG_*env vars.GitHook._process_git_auth_url(): Calls_set_http_auth_env()when HTTPS/HTTP + auth_token.GitDagBundle._fetch_bare_repo(): Passes all env vars (SSH + HTTP auth) instead of only SSH.Backward compatibility
GIT_CONFIG_*vars are set for SSH URLs).GIT_CONFIG_*env vars require git >= 2.31 (March 2021).Tests
Closes #54829
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com