review-comments: unwrap error in upload-sarif-action and re-classify as ConfigurationError if in known error category

This commit is contained in:
Fotis Koutoulakis (@NlightNFotis) 2025-04-02 15:20:03 +01:00
parent efd29bef22
commit 498c7f37e8
6 changed files with 21 additions and 7 deletions

View file

@ -80,7 +80,6 @@ async function run() {
await sendSuccessStatusReport(startedAt, uploadResult.statusReport, logger);
}
catch (unwrappedError) {
const isThirdPartyAnalysis = !(0, status_report_1.isFirstPartyAnalysis)(status_report_1.ActionName.UploadSarif);
// This is testing the error to check if it belongs to one of two categories we reliably
// know to be configuration errors in certain cases.
const configurationErrorCandidate =
@ -88,7 +87,8 @@ async function run() {
unwrappedError instanceof upload_lib.InvalidSarifUploadError ||
// There was a problem validating the JSON (SARIF) file.
unwrappedError instanceof SyntaxError;
const error = isThirdPartyAnalysis && configurationErrorCandidate
const error = (0, status_report_1.isThirdPartyAnalysis)(status_report_1.ActionName.UploadSarif) &&
configurationErrorCandidate
? new util_1.ConfigurationError(unwrappedError.message)
: (0, util_1.wrapError)(unwrappedError);
const message = error.message;