| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
This PR fixes an issue where the upload-sarif Action fails when there are no Code Scanning SARIF files, specifically for code quality-only analysis. It refactors the upload process to handle both Code Scanning and Code Quality SARIF files more gracefully and adds new outputs for tracking uploaded SARIF IDs.
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file| File | Description |
|---|---|
| upload-sarif/action.yml | Updates output descriptions and adds new sarif-ids output |
| src/upload-sarif-action.ts | Refactors upload logic with new findAndUpload function and combined status reporting |
| src/upload-lib.ts | Adds combineSarifUploadResults function to merge upload status reports |
| pr-checks/checks/upload-quality-sarif.yml | Updates test to use code-quality only and validates new output |
| lib/upload-sarif-action.js | Generated JavaScript code reflecting TypeScript changes |
| lib/upload-lib.js | Generated JavaScript code with new export for combine function |
| .github/workflows/__upload-quality-sarif.yml | Auto-generated workflow file updated for code-quality only testing |
Sorry, something went wrong.
There was a problem hiding this comment.
Can you motivate the Disable cpp in upload-quality-sarif check commit?
Sorry, something went wrong.
| await sendSuccessStatusReport(startedAt, uploadResult.statusReport, logger); | ||
| await sendSuccessStatusReport( | ||
| startedAt, | ||
| uploadResult?.statusReport || {}, |
There was a problem hiding this comment.
Is it convention to add the empty object to these statuses by default?
Sorry, something went wrong.
There was a problem hiding this comment.
Note that this was an intermediate commit and the {} just made the type checker happy until I replaced it with the statusReport from the Code Quality upload or the combination of both uploads.
The three properties of UploadStatusReport are all of type number | undefined, but the UploadStatusReport object itself is required here by sendSuccessStatusReport.
Previously, with only Code Scanning, we only would have reached sendSuccessStatusReport if the SARIF upload to Code Scanning is successful. In that case, the UploadStatusReport object always would have been populated.
Now we also have Code Quality and Code Scanning + Code Quality. So the status report should include the results of the respective upload(s).
Sorry, something went wrong.
| for (const report of reports) { | ||
| if (report !== undefined) { | ||
| result.num_results_in_sarif = addOptional( | ||
| result.num_results_in_sarif, | ||
| report.num_results_in_sarif, | ||
| ); | ||
| result.raw_upload_size_bytes = addOptional( | ||
| result.raw_upload_size_bytes, | ||
| report.raw_upload_size_bytes, | ||
| ); | ||
| result.zipped_upload_size_bytes = addOptional( | ||
| result.zipped_upload_size_bytes, | ||
| report.zipped_upload_size_bytes, | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
This is too ad hoc for my taste. Once we add a new numeric field to the type, it will get dropped when going through this function
Sorry, something went wrong.
There was a problem hiding this comment.
I.e. something like
for (const report of reports) {
if (!report) continue;
for (const key of Object.keys(report) as (keyof UploadStatusReport)[]) {
const value = report[key];
if (typeof value !== "number") continue; // Skip non-numeric / undefined
result[key] = ((result[key] ?? 0) as number) + value;
}
}
Conversely, we now risk adding things that can't be added...
Ultimately, we could do some typescript magic where we'd force ourselves to list every numerically typed property as being added or ignored, but that is complex.
Sorry, something went wrong.
There was a problem hiding this comment.
We could do something like that. Perhaps it is best if we leave sorting out the telemetry for a separate change so that we can think about this independently from the bug fix -- see my thoughts in the PR description and in #3123 (comment)
Sorry, something went wrong.
@esbena C++ has no queries in the code-quality suite and the CLI fails as a result. See https://github.com/github/codeql-action/actions/runs/17831231939/job/50696560032?pr=3123#step:5:892 |
Sorry, something went wrong.
There was a problem hiding this comment.
Perhaps it is best if we leave sorting out the telemetry for a separate change so that we can think about this independently from the bug fix
OK and conditional approve if we do that change elsewhere.
Sorry, something went wrong.
Unlike `sarif-id` which is for the single Code Scanning SARIF id, `sarif-ids` contains stringified JSON object with details of all SARIF ids.
|
I've removed the telemetry changes, other than that in the CQ-only case we send an empty UploadStatusReport. I think that's better than setting the fields to 0 since it allows us to tell apart status reports for CS/CS+CQ that have the data for CS from those that are for CQ-only and have no data. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
In #3064, we overlooked that upload_lib.uploadFiles is called in the upload-sarif Action, which will fail if it cannot find any SARIF files matching the predicate it is given.
For a Code Quality only analysis, there are no Code Scanning SARIF files and the call to upload_lib.uploadFiles therefore fails before the Code Quality SARIF file(s) can be uploaded.
This PR refactors the upload-sarif Action so that there's common code for Code Scanning and Code Quality to upload either one file or several matching files.
There are some optional, other changes in this PR as well, which I can remove if needed:
Risk assessment
For internal use only. Please select the risk level of this change:
Merge / deployment checklist