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

feat: improve error message in case of 401 after the retries in the first 5 seconds #168

Merged
merged 4 commits into from
Sep 14, 2020

Conversation

gr2m
Copy link
Contributor

@gr2m gr2m commented Sep 10, 2020

fixes #163

@gr2m gr2m added the Type: Feature New feature or request label Sep 10, 2020

requestWithAuth("GET /repos/octocat/hello-world").catch((error) => {
expect(error.message).toBe(
`[@octokit/auth-app] After 3 retries within 6s after creating the installation access token, the response remains 401. At this point it's unlikely a replication lag, but a legit authentication problem or a system outage, please check https://www.githubstatus.com/`
Copy link
Contributor Author

@gr2m gr2m Sep 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gwestersf @imwiss This is the error message people will see when the request retries fail to account for the installation access token replication lag. Let me know if you'd like me to rephrase it in any way.

This is just the message, the error has extra properties by default with more information.

    RequestError [HttpError]: [@octokit/auth-app] After 3 retries within 6s after creating the installation access token, the response remains 401. At this point it's unlikely a replication lag, but a legit authentication problem or a system outage, please check https://www.githubstatus.com/
        at /Users/gregor/Projects/octokit/auth-app.js/node_modules/@octokit/request/dist-src/fetch-wrapper.js:49:31
        at sendRequestWithRetries (/Users/gregor/Projects/octokit/auth-app.js/src/hook.ts:65:12) {
      status: 401,
      headers: { 'content-length': '83', 'content-type': 'application/json' },
      request: {
        method: 'GET',
        url: 'https://api.github.com/repos/octocat/hello-world',
        headers: {
          accept: 'application/vnd.github.v3+json',
          'user-agent': 'test',
          authorization: 'token [REDACTED]'
        },
      },
      documentation_url: 'https://developer.github.com/v3'
    }

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ping 👍 Additionally, are there any error messages returned by the API with the 401 that would make sense to surface in Octokit's error message?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting suggestion:

After 3 retries within 6s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any error messages returned by the API with the 401 that would make sense to surface in Octokit's error message

No. The only other information is documentation_url which we add to the error object.

error.message = `[@octokit/auth-app] After ${retries} retries within ${
timeSinceTokenCreationInMs / 1000
}s after creating the installation access token, the response remains 401. At this point it's unlikely a replication lag, but a legit authentication problem or a system outage, please check https://www.githubstatus.com/`;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only relevant change, the changes below are just reformatting for readability

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on line 52 should be updated to 5 seconds instead of 1 minute.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch 👍🏼

@gr2m gr2m self-assigned this Sep 10, 2020
@gr2m gr2m requested a review from gwestersf September 10, 2020 18:52
Copy link

@imwiss imwiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments / questions 👍


requestWithAuth("GET /repos/octocat/hello-world").catch((error) => {
expect(error.message).toBe(
`[@octokit/auth-app] After 3 retries within 6s after creating the installation access token, the response remains 401. At this point it's unlikely a replication lag, but a legit authentication problem or a system outage, please check https://www.githubstatus.com/`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ping 👍 Additionally, are there any error messages returned by the API with the 401 that would make sense to surface in Octokit's error message?


requestWithAuth("GET /repos/octocat/hello-world").catch((error) => {
expect(error.message).toBe(
`[@octokit/auth-app] After 3 retries within 6s after creating the installation access token, the response remains 401. At this point it's unlikely a replication lag, but a legit authentication problem or a system outage, please check https://www.githubstatus.com/`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting suggestion:

After 3 retries within 6s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information.

error.message = `[@octokit/auth-app] After ${retries} retries within ${
timeSinceTokenCreationInMs / 1000
}s after creating the installation access token, the response remains 401. At this point it's unlikely a replication lag, but a legit authentication problem or a system outage, please check https://www.githubstatus.com/`;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on line 52 should be updated to 5 seconds instead of 1 minute.

Copy link

@imwiss imwiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@gr2m gr2m merged commit bc1f5d6 into master Sep 14, 2020
@gr2m gr2m deleted the 163/improve-error-message-for-replication-lag branch September 14, 2020 18:22
@github-actions
Copy link
Contributor

🎉 This PR is included in version 2.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error message in case of 401 after the retries in the first 5 seconds
2 participants