From 4dcc8a9cdcf5d368149b2b117efe19f1095d58d6 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Thu, 29 Jan 2026 10:28:55 +0000 Subject: [PATCH] Move failed status report code into `sendFailedStatusReport` --- lib/start-proxy-action.js | 39 +++++++++++++++++++++------------------ src/start-proxy-action.ts | 29 +++-------------------------- src/start-proxy.ts | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 44 deletions(-) diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index def58d827..7faaa97bb 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -21329,7 +21329,7 @@ var require_core = __commonJS({ exports2.getBooleanInput = getBooleanInput; exports2.setOutput = setOutput2; exports2.setCommandEcho = setCommandEcho; - exports2.setFailed = setFailed2; + exports2.setFailed = setFailed3; exports2.isDebug = isDebug2; exports2.debug = debug5; exports2.error = error3; @@ -21413,7 +21413,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); function setCommandEcho(enabled) { (0, command_1.issue)("echo", enabled ? "on" : "off"); } - function setFailed2(message) { + function setFailed3(message) { process.exitCode = ExitCode.Failure; error3(message); } @@ -119590,6 +119590,24 @@ async function sendSuccessStatusReport(startedAt, config, registry_types, logger await sendStatusReport(statusReport); } } +async function sendFailedStatusReport(logger, startedAt, language, unwrappedError) { + const error3 = wrapError(unwrappedError); + core10.setFailed(`start-proxy action failed: ${error3.message}`); + const errorStatusReportBase = await createStatusReportBase( + "start-proxy" /* StartProxy */, + getActionsStatus(error3), + startedAt, + { + languages: language && [language] + }, + await checkDiskUsage(logger), + logger, + "Error from start-proxy Action omitted" + ); + if (errorStatusReportBase !== void 0) { + await sendStatusReport(errorStatusReportBase); + } +} var UPDATEJOB_PROXY = "update-job-proxy"; var UPDATEJOB_PROXY_VERSION = "v2.0.20250624110901"; var UPDATEJOB_PROXY_URL_PREFIX = "https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.22.0/"; @@ -119831,22 +119849,7 @@ async function run(startedAt) { logger ); } catch (unwrappedError) { - const error3 = wrapError(unwrappedError); - core11.setFailed(`start-proxy action failed: ${error3.message}`); - const errorStatusReportBase = await createStatusReportBase( - "start-proxy" /* StartProxy */, - getActionsStatus(error3), - startedAt, - { - languages: language && [language] - }, - await checkDiskUsage(logger), - logger, - "Error from start-proxy Action omitted" - ); - if (errorStatusReportBase !== void 0) { - await sendStatusReport(errorStatusReportBase); - } + await sendFailedStatusReport(logger, startedAt, language, unwrappedError); } } async function runWrapper() { diff --git a/src/start-proxy-action.ts b/src/start-proxy-action.ts index 439e730f6..531dcbb7b 100644 --- a/src/start-proxy-action.ts +++ b/src/start-proxy-action.ts @@ -15,16 +15,11 @@ import { getCredentials, getDownloadUrl, parseLanguage, + sendFailedStatusReport, sendSuccessStatusReport, UPDATEJOB_PROXY, } from "./start-proxy"; -import { - ActionName, - createStatusReportBase, - getActionsStatus, - sendStatusReport, - sendUnhandledErrorStatusReport, -} from "./status-report"; +import { ActionName, sendUnhandledErrorStatusReport } from "./status-report"; import * as util from "./util"; const KEY_SIZE = 2048; @@ -152,25 +147,7 @@ async function run(startedAt: Date) { logger, ); } catch (unwrappedError) { - const error = util.wrapError(unwrappedError); - core.setFailed(`start-proxy action failed: ${error.message}`); - - // We skip sending the error message and stack trace here to avoid the possibility - // of leaking any sensitive information into the telemetry. - const errorStatusReportBase = await createStatusReportBase( - ActionName.StartProxy, - getActionsStatus(error), - startedAt, - { - languages: language && [language], - }, - await util.checkDiskUsage(logger), - logger, - "Error from start-proxy Action omitted", - ); - if (errorStatusReportBase !== undefined) { - await sendStatusReport(errorStatusReportBase); - } + await sendFailedStatusReport(logger, startedAt, language, unwrappedError); } } diff --git a/src/start-proxy.ts b/src/start-proxy.ts index 32b8389bd..c527239e5 100644 --- a/src/start-proxy.ts +++ b/src/start-proxy.ts @@ -9,6 +9,7 @@ import { Logger } from "./logging"; import { ActionName, createStatusReportBase, + getActionsStatus, sendStatusReport, StatusReportBase, } from "./status-report"; @@ -52,6 +53,41 @@ export async function sendSuccessStatusReport( } } +/** + * Sends a status report for the `start-proxy` action indicating a failure. + * + * @param logger The logger to use. + * @param startedAt When the action was started. + * @param language The language provided as input, if any. + * @param unwrappedError The exception that was thrown. + */ +export async function sendFailedStatusReport( + logger: Logger, + startedAt: Date, + language: KnownLanguage | undefined, + unwrappedError: unknown, +) { + const error = util.wrapError(unwrappedError); + core.setFailed(`start-proxy action failed: ${error.message}`); + + // We skip sending the error message and stack trace here to avoid the possibility + // of leaking any sensitive information into the telemetry. + const errorStatusReportBase = await createStatusReportBase( + ActionName.StartProxy, + getActionsStatus(error), + startedAt, + { + languages: language && [language], + }, + await util.checkDiskUsage(logger), + logger, + "Error from start-proxy Action omitted", + ); + if (errorStatusReportBase !== undefined) { + await sendStatusReport(errorStatusReportBase); + } +} + export const UPDATEJOB_PROXY = "update-job-proxy"; export const UPDATEJOB_PROXY_VERSION = "v2.0.20250624110901"; const UPDATEJOB_PROXY_URL_PREFIX =