Skip to content
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

Error: API responded with 307 status #27

Open
rwjblue opened this issue Jun 12, 2019 · 1 comment
Open

Error: API responded with 307 status #27

rwjblue opened this issue Jun 12, 2019 · 1 comment
Labels
bug Something isn't working library Relates to an Origami library

Comments

@rwjblue
Copy link

rwjblue commented Jun 12, 2019

What

When the GitHub API returns a 307 (temporary redirect), an error is thrown:

Error: API responded with 307 status
    at /Users/rjackson/.npm/_npx/86941/lib/node_modules/create-rwjblue-release-it-setup/node_modules/github-label-sync/lib/github-label-api.js:88:20
    at Client.errorHandle (/Users/rjackson/.npm/_npx/86941/lib/node_modules/create-rwjblue-release-it-setup/node_modules/octonode/lib/octonode/client.js:206:14)
    at Request._callback (/Users/rjackson/.npm/_npx/86941/lib/node_modules/create-rwjblue-release-it-setup/node_modules/octonode/lib/octonode/client.js:338:24)
    at Request.self.callback (/Users/rjackson/.npm/_npx/86941/lib/node_modules/create-rwjblue-release-it-setup/node_modules/request/request.js:185:22)
    at Request.emit (events.js:196:13)
    at Request.<anonymous> (/Users/rjackson/.npm/_npx/86941/lib/node_modules/create-rwjblue-release-it-setup/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:196:13)
    at IncomingMessage.<anonymous> (/Users/rjackson/.npm/_npx/86941/lib/node_modules/create-rwjblue-release-it-setup/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:284:20)

Details

Per the GitHub V3 API Documentation:

API v3 uses HTTP redirection where appropriate. Clients should assume that any request may result in a redirection. Receiving an HTTP redirection is not an error and clients should follow that redirect. Redirect responses will have a Location header field which contains the URI of the resource to which the client should repeat the requests.

Instead of throwing an error here:

if (status !== 200) {
return reject(new Error(`API responded with ${status} status`));
}

We should use the Location header and make another request.

@JakeChampion
Copy link
Contributor

@rwjblue Excellent point, we would be willing to accept a pull-request which adds this functionality, if you wanted to add it :-)

@JakeChampion JakeChampion added bug Something isn't working library Relates to an Origami library labels Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working library Relates to an Origami library
Projects
None yet
Development

No branches or pull requests

2 participants