Skip to content

Commit f9d4372

Browse files
committed
[PLUTO-1396] Handle sarif err
1 parent f225ba3 commit f9d4372

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

utils/sarif.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,11 @@ func createEmptySarifReport() []byte {
261261
},
262262
},
263263
}
264-
sarifData, _ := json.MarshalIndent(emptyReport, "", " ")
264+
sarifData, err := json.MarshalIndent(emptyReport, "", " ")
265+
if err != nil {
266+
fmt.Fprintf(os.Stderr, "Error marshaling empty SARIF report: %v\n", err)
267+
return []byte("{}")
268+
}
265269
return sarifData
266270
}
267271

@@ -294,7 +298,11 @@ func createEmptySarifReportWithError(errorMessage string) []byte {
294298
},
295299
},
296300
}
297-
sarifData, _ := json.MarshalIndent(emptyReport, "", " ")
301+
sarifData, err := json.MarshalIndent(emptyReport, "", " ")
302+
if err != nil {
303+
fmt.Fprintf(os.Stderr, "Error marshaling SARIF report with error: %v\n", err)
304+
return []byte("{}")
305+
}
298306
return sarifData
299307
}
300308

0 commit comments

Comments
 (0)