Skip to content

Commit c45840d

Browse files
committed
Add common CLI configuration error categories
1 parent 4075abf commit c45840d

3 files changed

Lines changed: 71 additions & 1 deletion

File tree

lib/cli-errors.js

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

lib/cli-errors.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli-errors.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,16 @@ function ensureEndsInPeriod(text: string): string {
9999

100100
/** Error messages from the CLI that we consider configuration errors and handle specially. */
101101
export enum CliConfigErrorCategory {
102+
DetectedCodeButCouldNotProcess = "DetectedCodeButCouldNotProcess",
102103
IncompatibleWithActionVersion = "IncompatibleWithActionVersion",
103104
InitCalledTwice = "InitCalledTwice",
104105
InvalidSourceRoot = "InvalidSourceRoot",
105106
NoJavaScriptTypeScriptCodeFound = "NoJavaScriptTypeScriptCodeFound",
107+
NoBuildCommandAutodetected = "NoBuildCommandAutodetected",
108+
NoBuildMethodAutodetected = "NoBuildMethodAutodetected",
109+
NoSupportedBuildCommandSucceeded = "NoSupportedBuildCommandSucceeded",
110+
NoSupportedBuildSystemDetected = "NoSupportedBuildSystemDetected",
111+
NoSupportedLanguagesDetected = "NoSupportedLanguagesDetected",
106112
}
107113

108114
type CliErrorConfiguration = {
@@ -121,6 +127,16 @@ export const cliErrorsConfig: Record<
121127
CliConfigErrorCategory,
122128
CliErrorConfiguration
123129
> = {
130+
// Usually when a manual build script has failed, or if an autodetected language
131+
// was unintended to have CodeQL analysis run on it.
132+
[CliConfigErrorCategory.DetectedCodeButCouldNotProcess]: {
133+
exitCode: 32,
134+
cliErrorMessageSnippets: [
135+
"CodeQL detected code written in",
136+
"but could not process any of it",
137+
],
138+
additionalErrorMessageToPrepend: `Check the build script, if applicable, for the language specified in the error:`,
139+
},
124140
// Version of CodeQL CLI is incompatible with this version of the CodeQL Action
125141
[CliConfigErrorCategory.IncompatibleWithActionVersion]: {
126142
cliErrorMessageSnippets: ["is not compatible with this CodeQL CLI"],
@@ -151,6 +167,25 @@ export const cliErrorsConfig: Record<
151167
"No code found during the build. Please see: " +
152168
"https://gh.io/troubleshooting-code-scanning/no-source-code-seen-during-build.",
153169
},
170+
[CliConfigErrorCategory.NoBuildCommandAutodetected]: {
171+
cliErrorMessageSnippets: ["Could not auto-detect a suitable build method"],
172+
},
173+
[CliConfigErrorCategory.NoBuildMethodAutodetected]: {
174+
cliErrorMessageSnippets: [
175+
"Could not detect a suitable build command for the source checkout",
176+
],
177+
},
178+
[CliConfigErrorCategory.NoSupportedBuildCommandSucceeded]: {
179+
cliErrorMessageSnippets: ["No supported build command succeeded"],
180+
},
181+
[CliConfigErrorCategory.NoSupportedBuildSystemDetected]: {
182+
cliErrorMessageSnippets: ["No supported build system detected"],
183+
},
184+
[CliConfigErrorCategory.NoSupportedLanguagesDetected]: {
185+
cliErrorMessageSnippets: [
186+
"CodeQL did not detect any code written in languages supported by CodeQL",
187+
],
188+
},
154189
};
155190

156191
// Check if the given CLI error or exit code, if applicable, apply to any known

0 commit comments

Comments
 (0)