-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DownloadReleaseAsset breaks with renamed repository #3081
Comments
Could this be related to #3043 ? |
I don't think so, no. The two problems, as I understand them, are: One: go-github/github/repos_releases.go Line 390 in 454c1dd
because this API requires application/octet-stream to download the asset. This line should use that as the Two: go-github/github/repos_releases.go Line 370 in 454c1dd
uses #3051 (the PR that closed #3043) could be a problem if |
@dnephin - thanks for the explanation. Since you seem to have a better grasp of this than myself, would you like to put together a PR to solve these issues? |
DownloadReleaseAsset
breaks when a repository is renamed. You can see a reproduction of this here on a repository that I renamed fromgo-github-issue-demo
togo-github-issue-demo-1
.The code expects to receive exactly 1 redirect, which is to download the asset from the media server. However, if the repository is renamed, GitHub redirects once more to the new repository name. On following the redirect,
downloadReleaseAssetFromURL
code below sets a different accept header which causes the API server to respond with the release metadata rather than contents (docs):go-github/github/repos_releases.go
Line 390 in 454c1dd
The test I linked above is a minimal reproduction but it's worth noting that we actually discovered this in a different way: attempting to download a release for a renamed private repository actually returns a 401 Unauthorized, as when the redirect is followed the client also omits authentication (for actual release asset downloads, GitHub puts a token in the query params). We were following the function documentation and passing
http.DefaultClient
, rather than our authenticating HTTP client that was used to originally construct the GHE API client.The text was updated successfully, but these errors were encountered: