Add catch-all error reporting for errors that slip through run

This commit is contained in:
Henry Mercer
2026-01-22 13:14:53 +00:00
parent 14bd76753f
commit 229e0cd749
17 changed files with 447 additions and 101 deletions

117
lib/init-action-post.js generated
View File

@@ -27121,7 +27121,7 @@ var require_light = __commonJS({
}
return this.Events.trigger("scheduled", { args: this.args, options: this.options });
}
async doExecute(chained, clearGlobalState, run2, free) {
async doExecute(chained, clearGlobalState, run3, free) {
var error3, eventInfo, passed;
if (this.retryCount === 0) {
this._assertStatus("RUNNING");
@@ -27141,10 +27141,10 @@ var require_light = __commonJS({
}
} catch (error1) {
error3 = error1;
return this._onFailure(error3, eventInfo, clearGlobalState, run2, free);
return this._onFailure(error3, eventInfo, clearGlobalState, run3, free);
}
}
doExpire(clearGlobalState, run2, free) {
doExpire(clearGlobalState, run3, free) {
var error3, eventInfo;
if (this._states.jobStatus(this.options.id === "RUNNING")) {
this._states.next(this.options.id);
@@ -27152,9 +27152,9 @@ var require_light = __commonJS({
this._assertStatus("EXECUTING");
eventInfo = { args: this.args, options: this.options, retryCount: this.retryCount };
error3 = new BottleneckError$1(`This job timed out after ${this.options.expiration} ms.`);
return this._onFailure(error3, eventInfo, clearGlobalState, run2, free);
return this._onFailure(error3, eventInfo, clearGlobalState, run3, free);
}
async _onFailure(error3, eventInfo, clearGlobalState, run2, free) {
async _onFailure(error3, eventInfo, clearGlobalState, run3, free) {
var retry3, retryAfter;
if (clearGlobalState()) {
retry3 = await this.Events.trigger("failed", error3, eventInfo);
@@ -27162,7 +27162,7 @@ var require_light = __commonJS({
retryAfter = ~~retry3;
this.Events.trigger("retry", `Retrying ${this.options.id} after ${retryAfter} ms`, eventInfo);
this.retryCount++;
return run2(retryAfter);
return run3(retryAfter);
} else {
this.doDone(eventInfo);
await free(this.options, eventInfo);
@@ -27800,17 +27800,17 @@ var require_light = __commonJS({
}
}
_run(index, job, wait) {
var clearGlobalState, free, run2;
var clearGlobalState, free, run3;
job.doRun();
clearGlobalState = this._clearGlobalState.bind(this, index);
run2 = this._run.bind(this, index, job);
run3 = this._run.bind(this, index, job);
free = this._free.bind(this, index, job);
return this._scheduled[index] = {
timeout: setTimeout(() => {
return job.doExecute(this._limiter, clearGlobalState, run2, free);
return job.doExecute(this._limiter, clearGlobalState, run3, free);
}, wait),
expiration: job.options.expiration != null ? setTimeout(function() {
return job.doExpire(clearGlobalState, run2, free);
return job.doExpire(clearGlobalState, run3, free);
}, wait + job.options.expiration) : void 0,
job
};
@@ -88091,8 +88091,8 @@ var require_async = __commonJS({
return callback(null, results);
}
while (readyTasks.length && runningTasks < concurrency) {
var run2 = readyTasks.shift();
run2();
var run3 = readyTasks.shift();
run3();
}
}
function addListener(taskName, fn) {
@@ -126644,8 +126644,8 @@ function getExtraOptionsEnvParam() {
}
function getToolNames(sarif) {
const toolNames = {};
for (const run2 of sarif.runs || []) {
const tool = run2.tool || {};
for (const run3 of sarif.runs || []) {
const tool = run3.tool || {};
const driver = tool.driver || {};
if (typeof driver.name === "string" && driver.name.length > 0) {
toolNames[driver.name] = true;
@@ -130773,6 +130773,27 @@ async function sendStatusReport(statusReport) {
);
}
}
async function sendUnexpectedErrorStatusReport(actionName, actionStartedAt, error3, logger) {
try {
const statusReport = await createStatusReportBase(
actionName,
"failure",
actionStartedAt,
void 0,
void 0,
logger,
void 0,
getErrorMessage(error3)
);
if (statusReport !== void 0) {
await sendStatusReport(statusReport);
}
} catch (e) {
logger.warning(
`Caught an exception while sending the error status report: ${e}.`
);
}
}
// src/upload-lib.ts
var fs15 = __toESM(require("fs"));
@@ -131861,9 +131882,9 @@ async function addFingerprints(sarif, sourceRoot, logger) {
`Adding fingerprints to SARIF file. See ${"https://docs.github.com/en/enterprise-cloud@latest/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#providing-data-to-track-code-scanning-alerts-across-runs" /* TRACK_CODE_SCANNING_ALERTS_ACROSS_RUNS */} for more information.`
);
const callbacksByFile = {};
for (const run2 of sarif.runs || []) {
const artifacts = run2.artifacts || [];
for (const result of run2.results || []) {
for (const run3 of sarif.runs || []) {
const artifacts = run3.artifacts || [];
for (const result of run3.results || []) {
const primaryLocation = (result.locations || [])[0];
if (!primaryLocation?.physicalLocation?.artifactLocation) {
logger.debug(
@@ -131964,25 +131985,25 @@ function combineSarifFiles(sarifFiles, logger) {
function areAllRunsProducedByCodeQL(sarifObjects) {
return sarifObjects.every((sarifObject) => {
return sarifObject.runs?.every(
(run2) => run2.tool?.driver?.name === "CodeQL"
(run3) => run3.tool?.driver?.name === "CodeQL"
);
});
}
function createRunKey(run2) {
function createRunKey(run3) {
return {
name: run2.tool?.driver?.name,
fullName: run2.tool?.driver?.fullName,
version: run2.tool?.driver?.version,
semanticVersion: run2.tool?.driver?.semanticVersion,
guid: run2.tool?.driver?.guid,
automationId: run2.automationDetails?.id
name: run3.tool?.driver?.name,
fullName: run3.tool?.driver?.fullName,
version: run3.tool?.driver?.version,
semanticVersion: run3.tool?.driver?.semanticVersion,
guid: run3.tool?.driver?.guid,
automationId: run3.automationDetails?.id
};
}
function areAllRunsUnique(sarifObjects) {
const keys = /* @__PURE__ */ new Set();
for (const sarifObject of sarifObjects) {
for (const run2 of sarifObject.runs) {
const key = JSON.stringify(createRunKey(run2));
for (const run3 of sarifObject.runs) {
const key = JSON.stringify(createRunKey(run3));
if (keys.has(key)) {
return false;
}
@@ -132085,9 +132106,9 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
function populateRunAutomationDetails(sarif, category, analysis_key, environment) {
const automationID = getAutomationID2(category, analysis_key, environment);
if (automationID !== void 0) {
for (const run2 of sarif.runs || []) {
if (run2.automationDetails === void 0) {
run2.automationDetails = {
for (const run3 of sarif.runs || []) {
if (run3.automationDetails === void 0) {
run3.automationDetails = {
id: automationID
};
}
@@ -132186,13 +132207,13 @@ function countResultsInSarif(sarif) {
if (!Array.isArray(parsedSarif.runs)) {
throw new InvalidSarifUploadError("Invalid SARIF. Missing 'runs' array.");
}
for (const run2 of parsedSarif.runs) {
if (!Array.isArray(run2.results)) {
for (const run3 of parsedSarif.runs) {
if (!Array.isArray(run3.results)) {
throw new InvalidSarifUploadError(
"Invalid SARIF. Missing 'results' array in run."
);
}
numResults += run2.results.length;
numResults += run3.results.length;
}
return numResults;
}
@@ -132483,9 +132504,9 @@ function handleProcessingResultForUnsuccessfulExecution(response, status, logger
}
function validateUniqueCategory(sarif, sentinelPrefix) {
const categories = {};
for (const run2 of sarif.runs) {
const id = run2?.automationDetails?.id;
const tool = run2.tool?.driver?.name;
for (const run3 of sarif.runs) {
const id = run3?.automationDetails?.id;
const tool = run3.tool?.driver?.name;
const category = `${sanitize(id)}_${sanitize(tool)}`;
categories[category] = { id, tool };
}
@@ -132513,9 +132534,9 @@ function filterAlertsByDiffRange(logger, sarif) {
return sarif;
}
const checkoutPath = getRequiredInput("checkout_path");
for (const run2 of sarif.runs) {
if (run2.results) {
run2.results = run2.results.filter((result) => {
for (const run3 of sarif.runs) {
if (run3.results) {
run3.results = run3.results.filter((result) => {
const locations = [
...(result.locations || []).map((loc) => loc.physicalLocation),
...(result.relatedLocations || []).map((loc) => loc.physicalLocation)
@@ -132881,9 +132902,8 @@ function getFinalJobStatus() {
}
// src/init-action-post.ts
async function runWrapper() {
async function run2(startedAt) {
const logger = getActionsLogger();
const startedAt = /* @__PURE__ */ new Date();
let config;
let uploadFailedSarifResult;
let dependencyCachingUsage;
@@ -132958,6 +132978,21 @@ async function runWrapper() {
logger.info("Status report sent for init-post step.");
}
}
async function runWrapper() {
const startedAt = /* @__PURE__ */ new Date();
const logger = getActionsLogger();
try {
await run2(startedAt);
} catch (error3) {
core17.setFailed(`init post action failed: ${wrapError(error3).message}`);
await sendUnexpectedErrorStatusReport(
"init-post" /* InitPost */,
startedAt,
error3,
logger
);
}
}
void runWrapper();
/*! Bundled license information: