review-comments: unwrap error in upload-sarif-action and re-classify as ConfigurationError if in known error category
This commit is contained in:
parent
efd29bef22
commit
498c7f37e8
6 changed files with 21 additions and 7 deletions
|
|
@ -55,6 +55,13 @@ export function isFirstPartyAnalysis(actionName: ActionName): boolean {
|
|||
return process.env[EnvVar.INIT_ACTION_HAS_RUN] === "true";
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns true if the analysis is considered to be third party.
|
||||
*/
|
||||
export function isThirdPartyAnalysis(actionName: ActionName): boolean {
|
||||
return !isFirstPartyAnalysis(actionName);
|
||||
}
|
||||
|
||||
export type ActionStatus =
|
||||
| "aborted" // Only used in the init Action, if init failed before initializing the tracer due to something other than a configuration error.
|
||||
| "failure"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
StatusReportBase,
|
||||
getActionsStatus,
|
||||
ActionName,
|
||||
isFirstPartyAnalysis,
|
||||
isThirdPartyAnalysis,
|
||||
} from "./status-report";
|
||||
import * as upload_lib from "./upload-lib";
|
||||
import {
|
||||
|
|
@ -104,7 +104,6 @@ async function run() {
|
|||
}
|
||||
await sendSuccessStatusReport(startedAt, uploadResult.statusReport, logger);
|
||||
} catch (unwrappedError) {
|
||||
const isThirdPartyAnalysis = !isFirstPartyAnalysis(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 =
|
||||
|
|
@ -113,7 +112,8 @@ async function run() {
|
|||
// There was a problem validating the JSON (SARIF) file.
|
||||
unwrappedError instanceof SyntaxError;
|
||||
const error =
|
||||
isThirdPartyAnalysis && configurationErrorCandidate
|
||||
isThirdPartyAnalysis(ActionName.UploadSarif) &&
|
||||
configurationErrorCandidate
|
||||
? new ConfigurationError(unwrappedError.message)
|
||||
: wrapError(unwrappedError);
|
||||
const message = error.message;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue