ljharb / repo-report

CLI to list all repos a user has access to, and report on their configuration in aggregate.
MIT License
24 stars 11 forks source link

Rate limit error is poorly handled #69

Open ljharb opened 2 years ago

ljharb commented 2 years ago

I triggered the rate limit again:

```sh $ repo-report ℹ config file found at /Users/ljharb/.repo-report.json... Usage: repo-report [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.