feat: reclassify InvalidSarifUploadError as a user-error when final status report is produced

This commit is contained in:
Fotis Koutoulakis (@NlightNFotis) 2025-03-31 12:22:18 +01:00
parent 72a2b1295e
commit f21cf0bbd7
6 changed files with 28 additions and 4 deletions

View file

@ -15,6 +15,7 @@ import {
setupActionsVars,
createTestConfig,
} from "./testing-utils";
import { InvalidSarifUploadError } from "./upload-lib";
import { BuildMode, ConfigurationError, withTmpDir, wrapError } from "./util";
setupTests(test);
@ -242,4 +243,12 @@ test("getActionStatus handling correctly various types of errors", (t) => {
"user-error",
"We still recognise a wrapped ConfigurationError as a user error",
);
t.is(
getActionsStatus(
new InvalidSarifUploadError("SyntaxError: Unexpected end of JSON input"),
),
"user-error",
"We recognise an InvalidSarifUploadError as a user error",
);
});

View file

@ -18,6 +18,7 @@ import { EnvVar } from "./environment";
import { getRef } from "./git-utils";
import { Logger } from "./logging";
import { getRepositoryNwo } from "./repository";
import { InvalidSarifUploadError } from "./upload-lib";
import {
ConfigurationError,
isHTTPError,
@ -173,7 +174,14 @@ export function getActionsStatus(
otherFailureCause?: string,
): ActionStatus {
if (error || otherFailureCause) {
return error instanceof ConfigurationError ? "user-error" : "failure";
if (
error instanceof ConfigurationError ||
error instanceof InvalidSarifUploadError
) {
return "user-error";
}
return "failure";
} else {
return "success";
}