Call `getAnalysisKinds` a second time, and ignore exceptions thrown d… · github/codeql-action@fa7bdf0

@@ -15,7 +15,7 @@ import {

1515

getTemporaryDirectory,

1616

persistInputs,

1717

} from "./actions-util";

18-

import { getAnalysisKinds } from "./analyses";

18+

import { AnalysisKind, getAnalysisKinds } from "./analyses";

1919

import { getGitHubVersion } from "./api-client";

2020

import {

2121

getDependencyCachingEnabled,

@@ -253,8 +253,20 @@ async function run() {

253253

);

254254255255

try {

256-

// This may throw a `ConfigurationError` before we have sent the `starting` status report.

257-

const analysisKinds = await getAnalysisKinds(logger);

256+

// Parsing the `analysis-kinds` input may throw a `ConfigurationError`, which we don't want before

257+

// we have called `sendStartingStatusReport` below. However, we want the analysis kinds for that status

258+

// report. To work around this, we ignore exceptions that are thrown here and then call `getAnalysisKinds`

259+

// a second time later. The second call will then throw the exception again. If `getAnalysisKinds` is

260+

// successful, the results are cached so that we don't duplicate the work in normal runs.

261+

let analysisKinds: AnalysisKind[] | undefined;

262+

try {

263+

analysisKinds = await getAnalysisKinds(logger);

264+

} catch (err) {

265+

logger.debug(

266+

`Failed to parse analysis kinds for 'starting' status report: ${getErrorMessage(err)}`,

267+

);

268+

}

269+258270

// Send a status report indicating that an analysis is starting.

259271

await sendStartingStatusReport(startedAt, { analysisKinds }, logger);

260272

const codeQLDefaultVersionInfo = await features.getDefaultCliVersion(

@@ -312,6 +324,7 @@ async function run() {

312324

}

313325

}

314326327+

analysisKinds = await getAnalysisKinds(logger);

315328

config = await initConfig({

316329

analysisKinds,

317330

languagesInput: getOptionalInput("languages"),