github-label-sync
github-label-sync copied to clipboard
Error: API responded with 307 status
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:
https://github.com/Financial-Times/github-label-sync/blob/40c09b0d3a89b4813fae98885736b79735f308be/lib/github-label-api.js#L27-L29
We should use the Location header and make another request.
@rwjblue Excellent point, we would be willing to accept a pull-request which adds this functionality, if you wanted to add it :-)