Skip to content

Commit

Permalink
Classify config file and out of disk CLI errors as config errors (#2297)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Mercer <henrymercer@github.com>
  • Loading branch information
angelapwen and henrymercer committed May 20, 2024
1 parent b46ca8c commit ebd27c0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
20 changes: 16 additions & 4 deletions lib/cli-errors.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/cli-errors.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions src/cli-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,18 @@ function ensureEndsInPeriod(text: string): string {
/** Error messages from the CLI that we consider configuration errors and handle specially. */
export enum CliConfigErrorCategory {
ExternalRepositoryCloneFailed = "ExternalRepositoryCloneFailed",
GracefulOutOfMemory = "GracefulOutOfMemory",
GradleBuildFailed = "GradleBuildFailed",
IncompatibleWithActionVersion = "IncompatibleWithActionVersion",
InitCalledTwice = "InitCalledTwice",
InvalidConfigFile = "InvalidConfigFile",
InvalidSourceRoot = "InvalidSourceRoot",
MavenBuildFailed = "MavenBuildFailed",
NoBuildCommandAutodetected = "NoBuildCommandAutodetected",
NoBuildMethodAutodetected = "NoBuildMethodAutodetected",
NoSourceCodeSeen = "NoSourceCodeSeen",
NoSupportedBuildCommandSucceeded = "NoSupportedBuildCommandSucceeded",
NoSupportedBuildSystemDetected = "NoSupportedBuildSystemDetected",
OutOfMemoryOrDisk = "OutOfMemoryOrDisk",
PackCannotBeFound = "PackCannotBeFound",
SwiftBuildFailed = "SwiftBuildFailed",
UnsupportedBuildMode = "UnsupportedBuildMode",
Expand All @@ -158,9 +159,6 @@ export const cliErrorsConfig: Record<
new RegExp("Failed to clone external Git repository"),
],
},
[CliConfigErrorCategory.GracefulOutOfMemory]: {
cliErrorMessageCandidates: [new RegExp("CodeQL is out of memory.")],
},
[CliConfigErrorCategory.GradleBuildFailed]: {
cliErrorMessageCandidates: [
new RegExp("[autobuild] FAILURE: Build failed with an exception."),
Expand All @@ -180,6 +178,12 @@ export const cliErrorsConfig: Record<
],
additionalErrorMessageToAppend: `Is the "init" action called twice in the same job?`,
},
[CliConfigErrorCategory.InvalidConfigFile]: {
cliErrorMessageCandidates: [
new RegExp("Config file .* is not valid"),
new RegExp("The supplied config file is empty"),
],
},
// Expected source location for database creation does not exist
[CliConfigErrorCategory.InvalidSourceRoot]: {
cliErrorMessageCandidates: [new RegExp("Invalid source root")],
Expand Down Expand Up @@ -214,7 +218,6 @@ export const cliErrorsConfig: Record<
),
],
},

[CliConfigErrorCategory.NoSupportedBuildCommandSucceeded]: {
cliErrorMessageCandidates: [
new RegExp("No supported build command succeeded"),
Expand All @@ -225,6 +228,15 @@ export const cliErrorsConfig: Record<
new RegExp("No supported build system detected"),
],
},
[CliConfigErrorCategory.OutOfMemoryOrDisk]: {
cliErrorMessageCandidates: [
new RegExp("CodeQL is out of memory."),
new RegExp("out of disk"),
new RegExp("No space left on device"),
],
additionalErrorMessageToAppend:
"For more information, see https://gh.io/troubleshooting-code-scanning/out-of-disk-or-memory",
},
[CliConfigErrorCategory.PackCannotBeFound]: {
cliErrorMessageCandidates: [
new RegExp(
Expand Down

0 comments on commit ebd27c0

Please sign in to comment.