Skip to content

Commit fa7bdf0

Browse files
committed
Call getAnalysisKinds a second time, and ignore exceptions thrown during the first call
1 parent 57c7b0a commit fa7bdf0

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

lib/init-action.js

Lines changed: 13 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/init-action.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
);
254254

255255
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
}
314326

327+
analysisKinds = await getAnalysisKinds(logger);
315328
config = await initConfig({
316329
analysisKinds,
317330
languagesInput: getOptionalInput("languages"),

0 commit comments

Comments
 (0)