From fa7bdf055936bea552da9c58f425daa8bb13d51d Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Fri, 17 Oct 2025 13:40:18 +0100 Subject: [PATCH] Call `getAnalysisKinds` a second time, and ignore exceptions thrown during the first call --- lib/init-action.js | 18 +++++++++++++----- src/init-action.ts | 19 ++++++++++++++++--- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/lib/init-action.js b/lib/init-action.js index 0c7936f84..dea48d3bf 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -86063,10 +86063,10 @@ function isAnalyzingPullRequest() { } // src/analyses.ts -var AnalysisKind = /* @__PURE__ */ ((AnalysisKind2) => { - AnalysisKind2["CodeScanning"] = "code-scanning"; - AnalysisKind2["CodeQuality"] = "code-quality"; - return AnalysisKind2; +var AnalysisKind = /* @__PURE__ */ ((AnalysisKind3) => { + AnalysisKind3["CodeScanning"] = "code-scanning"; + AnalysisKind3["CodeQuality"] = "code-quality"; + return AnalysisKind3; })(AnalysisKind || {}); var supportedAnalysisKinds = new Set(Object.values(AnalysisKind)); async function parseAnalysisKinds(input) { @@ -90800,7 +90800,14 @@ async function run() { getOptionalInput("source-root") || "" ); try { - const analysisKinds = await getAnalysisKinds(logger); + let analysisKinds; + try { + analysisKinds = await getAnalysisKinds(logger); + } catch (err) { + logger.debug( + `Failed to parse analysis kinds for 'starting' status report: ${getErrorMessage(err)}` + ); + } await sendStartingStatusReport(startedAt, { analysisKinds }, logger); const codeQLDefaultVersionInfo = await features.getDefaultCliVersion( gitHubVersion.type @@ -90848,6 +90855,7 @@ async function run() { logger.info("Experimental Rust analysis enabled"); } } + analysisKinds = await getAnalysisKinds(logger); config = await initConfig2({ analysisKinds, languagesInput: getOptionalInput("languages"), diff --git a/src/init-action.ts b/src/init-action.ts index 5196550e2..c6bfb136e 100644 --- a/src/init-action.ts +++ b/src/init-action.ts @@ -15,7 +15,7 @@ import { getTemporaryDirectory, persistInputs, } from "./actions-util"; -import { getAnalysisKinds } from "./analyses"; +import { AnalysisKind, getAnalysisKinds } from "./analyses"; import { getGitHubVersion } from "./api-client"; import { getDependencyCachingEnabled, @@ -253,8 +253,20 @@ async function run() { ); try { - // This may throw a `ConfigurationError` before we have sent the `starting` status report. - const analysisKinds = await getAnalysisKinds(logger); + // Parsing the `analysis-kinds` input may throw a `ConfigurationError`, which we don't want before + // we have called `sendStartingStatusReport` below. However, we want the analysis kinds for that status + // report. To work around this, we ignore exceptions that are thrown here and then call `getAnalysisKinds` + // a second time later. The second call will then throw the exception again. If `getAnalysisKinds` is + // successful, the results are cached so that we don't duplicate the work in normal runs. + let analysisKinds: AnalysisKind[] | undefined; + try { + analysisKinds = await getAnalysisKinds(logger); + } catch (err) { + logger.debug( + `Failed to parse analysis kinds for 'starting' status report: ${getErrorMessage(err)}`, + ); + } + // Send a status report indicating that an analysis is starting. await sendStartingStatusReport(startedAt, { analysisKinds }, logger); const codeQLDefaultVersionInfo = await features.getDefaultCliVersion( @@ -312,6 +324,7 @@ async function run() { } } + analysisKinds = await getAnalysisKinds(logger); config = await initConfig({ analysisKinds, languagesInput: getOptionalInput("languages"),