Skip to content

Commit 5e3939b

Browse files
committed
Display better error message on invalid sarif
Specifically, some third party tools do not include a `results` block for runs when there is an error. This change adds a more explicit error message for this situation.
1 parent ffd96b3 commit 5e3939b

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

lib/upload-lib.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/upload-lib.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ function getSarifFilePaths(sarifPath: string) {
177177
export function countResultsInSarif(sarif: string): number {
178178
let numResults = 0;
179179
for (const run of JSON.parse(sarif).runs) {
180+
if (!Array.isArray(run.results)) {
181+
throw new Error("Invalid SARIF. Missing 'results' block in run.");
182+
}
180183
numResults += run.results.length;
181184
}
182185
return numResults;

0 commit comments

Comments
 (0)