-
Notifications
You must be signed in to change notification settings - Fork 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
actions.downloadArtifact follows the redirect instead of returning the URL #1999
Comments
The documentation of the method is directly taken from GitHub's OpenAPI specification at https://github.com/github/rest-api-description/, we do not maintain these manually. We have several issues related to redirects are blocked by GitHub's API: https://github.com/octokit/rest.js/issues?q=is%3Aissue+is%3Aopen+label%3Ablocked If you work in Node, what I would recommend is to use a different request library to retrieve the redirect URL without following it automatically. That is something that cannot be done in browsers. I've been asking for a special media type to retrieve the redirect URL in the response body for a long time, unfortunately to no avail: https://gr2m.github.io/github-api-wishlist/wishlist/link-media-type/ Anyway, you can do this to retrieve the request options, then pass it to another request library const requestOptions = octokit.actions.downloadArtifact.endpoint({
owner,
repo,
artifact_id,
archive_format,
});
// token for Authorization header: `Authorization: token ${token}`
const { token } = await octokit.auth() You can also pass const { headers } = await octokit.actions.downloadArtifact({
request: {
// node-only fetch option: https://github.com/node-fetch/node-fetch#options
follow: 0
},
owner,
repo,
artifact_id,
archive_format,
}); |
@gr2m Thanks for the detailed answer! That looks like it should be a good workaround. I ended up going a different route entirely, though, that no longer involves downloading artifacts. Feel free to close this issue. |
I've encountered the same issue, and I was able to solve this with the const { headers } = await octokit.actions.downloadArtifact({
request: {
redirect: 'manual',
},
owner,
repo,
artifact_id,
archive_format,
}); |
Checklist
Environment
Versions
What happened?
According to the documentation
actions.downloadArtifact
should return a redirect URL for downloading the artifact. Instead it returns after following the redirect, which meansdata
contains the entire artifact as a buffer.Minimal test case to reproduce the problem
await octokit.actions.downloadArtifact
against the artifact.data
set to the buffer.What did you expect to happen?
According to the documentation, the API responds with a redirect and the response from octokit should be the URL (via the
location
header) which is good for one minute. This seems useful as the user might want to use something else to perform the download, e.g. to avoid loading hundreds of megabytes into memory.What the problem might be
The underlying `@octokit/request´ library likely follows redirects by default. Either the documentation of the method needs to be changed to reflect this behavior or the request needs to be performed in a way that ensures the redirect is not followed in this case.
The text was updated successfully, but these errors were encountered: