Scan can exhaust GitHub REST API rate limit when generating comments
mitchspano opened this issue · comments
Mitch Spano commented
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]
}
}
}
Nils Schuch commented
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"
}