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

fix: adapt to GitHub's rename of abuse limit to secondary rate limit #438

Merged
merged 2 commits into from
Sep 6, 2021

Conversation

dontcallmedom
Copy link
Contributor

close #437

@gr2m gr2m added the bug label Sep 6, 2021
@@ -121,7 +121,7 @@ export function throttling(octokit: Octokit, octokitOptions = {}) {
options.request.retryCount = retryCount;

const { wantRetry, retryAfter } = await (async function () {
if (/\babuse\b/i.test(error.message)) {
if (/\bsecondary rate\b/i.test(error.message)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The tests need to be updated. I can do that if you are busy, just let me know.

Do you by chance have the full response error object available, with both the response body and headers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if you can take care of updating the tests, that'd be great - thanks!

here is the full error log (this was from a graphql request generated by https://github.com/w3c/validate-repos):

  status: 403,
  response: {
    url: 'https://api.github.com/graphql',
    status: 403,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset',
      connection: 'close',
      'content-encoding': 'gzip',
      'content-security-policy': "default-src 'none'; base-uri 'self'; block-all-mixed-content; connect-src 'self' uploads.github.com www.githubstatus.com collector.githubapp.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com cdn.optimizely.com logx.optimizely.com/v1/events translator.github.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com; frame-ancestors 'none'; frame-src render.githubusercontent.com viewscreen.githubusercontent.com; img-src 'self' data: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com collector.githubapp.com avatars.githubusercontent.com github-cloud.s3.amazonaws.com secured-user-images.githubusercontent.com/; manifest-src 'self'; media-src 'none'; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com",
      'content-type': 'application/json; charset=utf-8',
      date: 'Mon, 06 Sep 2021 12:04:35 GMT',
      'expect-ct': 'max-age=2592000, report-uri="https://api.github.com/_private/browser/errors"',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      'retry-after': '60',
      server: 'GitHub.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      'transfer-encoding': 'chunked',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-media-type': 'github.v4; format=json',
      'x-github-request-id': '[REDACTED]',
      'x-xss-protection': '0'
    },
    data: {
      documentation_url: 'https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#secondary-rate-limits',
      message: 'You have exceeded a secondary rate limit. Please wait a few minutes before you try again.'
    }
  },
  request: {
    method: 'POST',
    url: 'https://api.github.com/graphql',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-core.js/3.5.1 Node.js/12.22.6 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"query":"\\n  query ($org: String!, $cursor: String) {\\n    organization(login: $org) {\\n      repositories(first: 10, after: $cursor) {\\n        nodes {\\n          id\\n          name\\n          owner {\\n            login\\n          }\\n          isArchived\\n          homepageUrl\\n          description\\n          isPrivate\\n          createdAt\\n          labels(first: 100) {\\n            nodes {\\n              name\\n              color\\n            }\\n            pageInfo {\\n              endCursor\\n              hasNextPage\\n            }\\n          }\\n          defaultBranch: defaultBranchRef {\\n            name\\n          }\\n          branchProtectionRules(first: 5) {\\n            nodes {\\n              pattern\\n              requiredApprovingReviewCount\\n              requiredStatusCheckContexts\\n              isAdminEnforced\\n            }\\n          }\\n          w3cjson: object(expression: \\"HEAD:w3c.json\\") {\\n            ... on Blob {\\n              text\\n            }\\n          }\\n          prpreviewjson: object(expression: \\"HEAD:.pr-preview.json\\") {\\n            ... on Blob {\\n              text\\n            }\\n          }\\n          autoPublish: object(expression: \\"HEAD:.github/workflows/auto-publish.yml\\") {\\n            ... on Blob {\\n              text\\n            }\\n          }\\n          travis: object(expression: \\"HEAD:.travis.yml\\") {\\n            ... on Blob {\\n              text\\n            }\\n          }\\n          contributing: object(expression: \\"HEAD:CONTRIBUTING.md\\") {\\n            ... on Blob {\\n              text\\n            }\\n          }\\n          license: object(expression: \\"HEAD:LICENSE.md\\") {\\n            ... on Blob {\\n              text\\n            }\\n          }\\n          codeOfConduct {\\n            body\\n          }\\n          readme: object(expression: \\"HEAD:README.md\\") {\\n            ... on Blob {\\n              text\\n            }\\n          }\\n        }\\n        pageInfo {\\n          endCursor\\n          hasNextPage\\n        }\\n      }\\n    }\\n  }\\n","variables":{"org":"w3c","cursor":"Y3Vyc29yOnYyOpHOB8UmtA=="}}',
    request: { hook: [Function: bound bound register] }
  }

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, thank you!

@gr2m gr2m changed the title Update abuse detection code to reflect GitHub's current error fix: adapt to GitHub's rename of abuse limit to secondary rate limit Sep 6, 2021
@gr2m gr2m merged commit 6c361d4 into octokit:master Sep 6, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2021

🎉 This PR is included in version 3.5.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

bflad added a commit to bflad/action-migrate-issue that referenced this pull request Dec 10, 2021
bflad added a commit to bflad/action-milestone-comment that referenced this pull request Dec 10, 2021
bflad added a commit to bflad/action-migrate-issue that referenced this pull request Dec 10, 2021
* Bump @octokit/plugin-throttling from 3.5.0 to 3.5.2

Bumps [@octokit/plugin-throttling](https://github.com/octokit/plugin-throttling.js) from 3.5.0 to 3.5.2.
- [Release notes](https://github.com/octokit/plugin-throttling.js/releases)
- [Commits](octokit/plugin-throttling.js@v3.5.0...v3.5.2)

---
updated-dependencies:
- dependency-name: "@octokit/plugin-throttling"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updates for GitHub secondary rate limit renaming

Reference: octokit/plugin-throttling.js#438

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brian Flad <bflad417@gmail.com>
bflad added a commit to bflad/action-milestone-comment that referenced this pull request Dec 10, 2021
* Bump @octokit/plugin-throttling from 3.4.2 to 3.5.2

Bumps [@octokit/plugin-throttling](https://github.com/octokit/plugin-throttling.js) from 3.4.2 to 3.5.2.
- [Release notes](https://github.com/octokit/plugin-throttling.js/releases)
- [Commits](octokit/plugin-throttling.js@v3.4.2...v3.5.2)

---
updated-dependencies:
- dependency-name: "@octokit/plugin-throttling"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updates for GitHub secondary rate limit renaming

Reference: octokit/plugin-throttling.js#438

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brian Flad <bflad417@gmail.com>
bflad added a commit to hashicorp/setup-hc-releases that referenced this pull request Dec 10, 2021
bflad added a commit to hashicorp/setup-hc-releases that referenced this pull request Dec 10, 2021
* Bump @octokit/plugin-throttling from 3.5.1 to 3.5.2

Bumps [@octokit/plugin-throttling](https://github.com/octokit/plugin-throttling.js) from 3.5.1 to 3.5.2.
- [Release notes](https://github.com/octokit/plugin-throttling.js/releases)
- [Commits](octokit/plugin-throttling.js@v3.5.1...v3.5.2)

---
updated-dependencies:
- dependency-name: "@octokit/plugin-throttling"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updates for GitHub secondary rate limit renaming

Reference: octokit/plugin-throttling.js#438

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brian Flad <bflad417@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Abuse rate limitation needs an update
2 participants