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

Scan can exhaust GitHub REST API rate limit when generating comments #6

Open
mitchspano opened this issue Aug 1, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@mitchspano
Copy link
Owner

mitchspano commented Aug 1, 2022

The scan has no protection against blowing through the GitHub REST API rate limit when many many comments are to be generated.

Writing comments using GitHub REST API...
WARNING: In September 2022, v3.x of the Salesforce Code Analyzer will become the default version,
         and older versions, including your currently installed version, will no longer be supported.
         You can manually update to v3.x earlier for a smoother transition.
WARNING: As of April 27, 2022, v3.x of the Salesforce Code Analyzer is available as an open pilot.
         To update to v3.x and try out our pilot features, run these commands:
         > sfdx plugins:uninstall @salesforce/sfdx-scanner
         > sfdx plugins:install @salesforce/sfdx-scanner@latest-pilot
/home/runner/work/_actions/mitchspano/sfdx-scan-pull-request/v0.1/dist/index.js:6544
      const error = new requestError.RequestError(toErrorMessage(data), status, {
                    ^

RequestError [HttpError]: Validation Failed: {"resource":"PullRequestReviewComment","code":"abuse","field":"base"}
    at /home/runner/work/_actions/mitchspano/sfdx-scan-pull-request/v0.1/dist/index.js:6544:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async writeComments (/home/runner/work/_actions/mitchspano/sfdx-scan-pull-request/v0.1/dist/index.js:7[17](https://github.com/rsoesemann/salesforce-recipes/runs/7617457933?check_suite_focus=true#step:4:18)01:7) {
  status: 4[22](https://github.com/rsoesemann/salesforce-recipes/runs/7617457933?check_suite_focus=true#step:4:23),
  response: {
    url: 'https://api.github.com/repos/rsoesemann/salesforce-recipes/pulls/2/comments',
    status: 422,
    
    ...
    
    data: {
      message: 'Validation Failed',
      errors: [
        {
          resource: 'PullRequestReviewComment',
          code: 'abuse',
          field: 'base'
        }
      ],
      documentation_url: 'https://docs.github.com/rest'
    }
  },
  request: {
    method: 'POST',
    url: 'https://api.github.com/repos/rsoesemann/salesforce-recipes/pulls/2/comments',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-action.js/4.0.4 octokit-core.js/4.0.4 Node.js/16.13.0 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: `{"commit_id":"7e02f10a68b649d3de0042b5e328[59](https://github.com/rsoesemann/salesforce-recipes/runs/7617457933?check_suite_focus=true#step:4:60)315ee38c33","path":"force-app/main/apex-domainbuilder/classes/Voldemort.cls","start_line":80,"start_side":"RIGHT","side":"RIGHT","line":81,"body":"| Engine | Category | Rule | Severity | Type |\\n| --- | --- | --- | --- | --- |\\n| pmd | Best Practices | UnusedLocalVariable | 5 | Error |\\n\\n[\\nVariable 'space' defined but not used\\n](https://pmd.github.io/pmd-6.47.0/pmd_rules_apex_bestpractices.html#unusedlocalvariable)"}`,
    request: {
      agent: ProxyAgent { promisifiedCallback: [Function (anonymous)] },
      hook: [Function: bound bound register]
    }
  }
}

https://docs.github.com/en/rest/rate-limit

@Schuchie
Copy link

Maybe not directly the same, but also hitting limits when to much comments are generated:
After following log output: Creating Check Runs using GitHub REST API...
"data": {
"message": "Invalid request.\n\nNo more than 50 items are allowed; 261 were supplied.",
"documentation_url": "https://docs.github.com/rest/checks/runs#create-a-check-run"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants