lfshttp: only add extra headers if they don't exist already #4369
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.
In actions/checkout#415 @Roda83 noted that Git LFS files are not downloaded within the GitHub Actions environment on GitHub Enterprise Server in certain cases.
The
checkout@v2
action uses Git'sextraheader
config to make the authentication easily available to all Git calls in the Action environment. At some point the Action runsgit lfs fetch
to download the LFS files and this works great.This call will download the "metadata" of the LFS files in batch with a
href
and anauthentication
header for each LFS file. Git LFS uses this info to make additional requests to download these files. Usually, these LFS files are downloaded from a different domain than the domain that the repository is cloned from (e.g.media.ghes-server.com
vsghes-server.com
). That's why theextraheader
is not applied to these requests.However, if GitHub Enterprise Server is not run in "subdomain isolation" mode, then the clone domain is equal to the LFS files domain. Consequently, the
extraheader
is applied. That means the requests will have twoauthentication
headers and because of that the request will fail.This PR fixes this issue by checking if a certain header already exists before we add an
extraheader
.I tried to add a test case for this but it turns out that the LFS batch response in our tests does not contain an
authentication
header. Therefore, we have no duplicate header and no problem./cc @dassencio @jonico