diff --git a/lib/entry-points.js b/lib/entry-points.js index bff941474f..15e1d5de49 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -182358,7 +182358,8 @@ var cliErrorsConfig = { new RegExp( "CodeQL did not detect any code written in languages supported by CodeQL" ) - ] + ], + additionalErrorMessageToAppend: "If automatic language detection selected a language that is absent from the checkout, set the `languages` input on the `init` step to the languages you want to analyze." }, ["NoSupportedBuildCommandSucceeded" /* NoSupportedBuildCommandSucceeded */]: { cliErrorMessageCandidates: [ diff --git a/src/cli-errors.test.ts b/src/cli-errors.test.ts index bb0e1b5d91..b05e8519e1 100644 --- a/src/cli-errors.test.ts +++ b/src/cli-errors.test.ts @@ -224,17 +224,25 @@ test("wrapCliConfigurationError - init called twice", (t) => { }); test("wrapCliConfigurationError - no source code seen by exit code", (t) => { + const diagnostic = + "CodeQL detected code written in JavaScript/TypeScript, but not any written in Python."; const commandError = new CommandInvocationError( "codeql", ["database", "finalize"], 32, - "Some other error message", + diagnostic, ); const cliError = new CliError(commandError); const wrappedError = wrapCliConfigurationError(cliError); t.true(wrappedError instanceof ConfigurationError); + t.true(wrappedError.message.includes(diagnostic)); + t.true( + wrappedError.message.includes( + "set the `languages` input on the `init` step to the languages you want to analyze.", + ), + ); }); test("wrapCliConfigurationError - no source code seen by message", (t) => { diff --git a/src/cli-errors.ts b/src/cli-errors.ts index 608413002c..b6fd0535bb 100644 --- a/src/cli-errors.ts +++ b/src/cli-errors.ts @@ -238,6 +238,9 @@ const cliErrorsConfig: Record = { "CodeQL did not detect any code written in languages supported by CodeQL", ), ], + additionalErrorMessageToAppend: + "If automatic language detection selected a language that is absent from the checkout, " + + "set the `languages` input on the `init` step to the languages you want to analyze.", }, [CliConfigErrorCategory.NoSupportedBuildCommandSucceeded]: { cliErrorMessageCandidates: [ diff --git a/unreleased-change-notes/no-source-code-language-guidance.md b/unreleased-change-notes/no-source-code-language-guidance.md new file mode 100644 index 0000000000..0df3acf384 --- /dev/null +++ b/unreleased-change-notes/no-source-code-language-guidance.md @@ -0,0 +1 @@ +- The CodeQL Action now suggests setting the `languages` input when automatic language detection selects a language that is absent from the checkout and CodeQL reports that it saw no source code. [#4335](https://github.com/github/codeql-action/pull/4335)