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

Rate limit error is poorly handled #69

Open
ljharb opened this issue Mar 2, 2022 · 0 comments
Open

Rate limit error is poorly handled #69

ljharb opened this issue Mar 2, 2022 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ljharb
Copy link
Owner

ljharb commented Mar 2, 2022

I triggered the rate limit again:

$ repo-report
ℹ config file found at /Users/ljharb/.repo-report.json...
Usage: repo-report <command> [options]

Commands:
  repo-report          Fetch actionable details about your public, source
                       (non-fork, non-template) repositories. Unactionable
                       metrics are converted to ✔ by default.          [default]
  repo-report ls       Lists all repositories.
                       - Includes sources, forks, templates, private, and public
                       repos by default.
  repo-report metrics  Show available metrics

Options:
      --version       Show version number                              [boolean]
      --config        Path to JSON config file
      --help          Show help                                        [boolean]
      --unactionable                                  [boolean] [default: false]
      --actual                                        [boolean] [default: false]
      --goodness                                       [boolean] [default: true]
  -m, --metrics                                       [boolean] [default: false]
      --all                                           [boolean] [default: false]
      --names                                         [boolean] [default: false]
  -s, --sort                                          [boolean] [default: false]
      --cache                                         [boolean] [default: false]

GraphqlResponseError: Request failed due to following response errors:
 - API rate limit exceeded for user ID 45469.
    at /Users/ljharb/Dropbox/git/ljharb/repo-report.git/node_modules/@octokit/graphql/dist-node/index.js:81:13
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getRepositories (/Users/ljharb/Dropbox/git/ljharb/repo-report.git/src/utils.js:125:20)
    at async getRepositories (/Users/ljharb/Dropbox/git/ljharb/repo-report.git/src/getRepositories.js:86:35)
    at async Object.detail [as handler] (/Users/ljharb/Dropbox/git/ljharb/repo-report.git/src/commands/detail.js:25:35) {
  request: {
    query: 'query {\n' +
      '  viewer {\n' +
      '\trepositories(\n' +
      '\t  first: 100\n' +
      '\t  affiliations: [OWNER, ORGANIZATION_MEMBER, COLLABORATOR]\n' +
      '\t  \n' +
      '\t  isFork: false\n' +
      '\t  privacy: PUBLIC\n' +
      '\t) {\n' +
      '\t  totalCount\n' +
      '\t  pageInfo {\n' +
      '\t\tendCursor\n' +
      '\t\thasNextPage\n' +
      '\t}\n' +
      '\tnodes {\n' +
      '\t\tname\n' +
      '\t\tnameWithOwner\n' +
      '\t\tdefaultBranchRef {\n' +
      '\t\t\tname\n' +
      '\t\t\tbranchProtectionRule {\n' +
      '\t\t\t\tallowsForcePushes\n' +
      '\t\t\t\tallowsDeletions\n' +
      '\t\t\t\tdismissesStaleReviews\n' +
      '\t\t\t\trequiredApprovingReviewCount\n' +
      '\t\t\t\trequiresApprovingReviews\n' +
      '\t\t\t\trequiresCodeOwnerReviews\n' +
      '\t\t\t\trequiresConversationResolution\n' +
      '\t\t\t\trestrictsPushes\n' +
      '\t\t\t}\n' +
      '\t\t}\n' +
      '\t\tdeleteBranchOnMerge\n' +
      '\t\thasIssuesEnabled\n' +
      '\t\thasProjectsEnabled\n' +
      '\t\thasWikiEnabled\n' +
      '\t\tforkingAllowed\n' +
      '\t\tisArchived\n' +
      '\t\tautoMergeAllowed\n' +
      '\t\tisBlankIssuesEnabled\n' +
      '\t\tisFork\n' +
      '\t\tisPrivate\n' +
      '\t\tisSecurityPolicyEnabled\n' +
      '\t\tisTemplate\n' +
      '\t\tlicenseInfo {\n' +
      '\t\t\tname\n' +
      '\t\t}\n' +
      '\t\tmergeCommitAllowed\n' +
      '\t\towner {\n' +
      '\t\t\tlogin\n' +
      '\t\t}\n' +
      '\t\trebaseMergeAllowed\n' +
      '\t\tsquashMergeAllowed\n' +
      '\t\tcreatedAt\n' +
      '\t\tupdatedAt\n' +
      '\t\tpushedAt\n' +
      '\t\tviewerHasStarred\n' +
      '\t\tviewerPermission\n' +
      '\t\tviewerSubscription\n' +
      '\t  }\n' +
      '\t}\n' +
      '  }\n' +
      '  rateLimit {\n' +
      '\tcost\n' +
      '\tremaining\n' +
      '  }\n' +
      '}\n',
    headers: { authorization: 'token $TOKEN' }
  },
  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, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
    connection: 'close',
    'content-encoding': 'gzip',
    'content-security-policy': "default-src 'none'",
    'content-type': 'application/json; charset=utf-8',
    date: 'Wed, 02 Mar 2022 21:35:24 GMT',
    'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
    server: 'GitHub.com',
    'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
    'transfer-encoding': 'chunked',
    vary: 'Accept-Encoding, Accept, X-Requested-With',
    'x-accepted-oauth-scopes': 'repo',
    'x-content-type-options': 'nosniff',
    'x-frame-options': 'deny',
    'x-github-media-type': 'github.v3; format=json',
    'x-github-request-id': 'D4B6:8A9B:5AE25D:61ACC3:621FE31C',
    'x-oauth-scopes': 'read:discussion, read:enterprise, read:gpg_key, read:org, read:packages, read:public_key, read:repo_hook, read:user, repo, user:email, user:follow',
    'x-ratelimit-limit': '5000',
    'x-ratelimit-remaining': '0',
    'x-ratelimit-reset': '1646257799',
    'x-ratelimit-resource': 'graphql',
    'x-ratelimit-used': '5000',
    'x-xss-protection': '0'
  },
  response: { errors: [ [Object] ] },
  errors: [
    {
      type: 'RATE_LIMITED',
      message: 'API rate limit exceeded for user ID 45469.'
    }
  ],
  data: undefined
}

We need to handle this error better. Additionally, note the $TOKEN (which i had to manually censor). The github token should never be printed to the console.

@ljharb ljharb added bug Something isn't working help wanted Extra attention is needed labels Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant