Classify config file and out of disk CLI errors as config errors (#2297)

Co-authored-by: Henry Mercer <henrymercer@github.com>
This commit is contained in:
Angela P Wen 2024-05-20 20:03:44 +02:00 committed by GitHub
parent b46ca8cee6
commit ebd27c09f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 10 deletions

20
lib/cli-errors.js generated
View file

@ -117,10 +117,10 @@ function ensureEndsInPeriod(text) {
var CliConfigErrorCategory; var CliConfigErrorCategory;
(function (CliConfigErrorCategory) { (function (CliConfigErrorCategory) {
CliConfigErrorCategory["ExternalRepositoryCloneFailed"] = "ExternalRepositoryCloneFailed"; CliConfigErrorCategory["ExternalRepositoryCloneFailed"] = "ExternalRepositoryCloneFailed";
CliConfigErrorCategory["GracefulOutOfMemory"] = "GracefulOutOfMemory";
CliConfigErrorCategory["GradleBuildFailed"] = "GradleBuildFailed"; CliConfigErrorCategory["GradleBuildFailed"] = "GradleBuildFailed";
CliConfigErrorCategory["IncompatibleWithActionVersion"] = "IncompatibleWithActionVersion"; CliConfigErrorCategory["IncompatibleWithActionVersion"] = "IncompatibleWithActionVersion";
CliConfigErrorCategory["InitCalledTwice"] = "InitCalledTwice"; CliConfigErrorCategory["InitCalledTwice"] = "InitCalledTwice";
CliConfigErrorCategory["InvalidConfigFile"] = "InvalidConfigFile";
CliConfigErrorCategory["InvalidSourceRoot"] = "InvalidSourceRoot"; CliConfigErrorCategory["InvalidSourceRoot"] = "InvalidSourceRoot";
CliConfigErrorCategory["MavenBuildFailed"] = "MavenBuildFailed"; CliConfigErrorCategory["MavenBuildFailed"] = "MavenBuildFailed";
CliConfigErrorCategory["NoBuildCommandAutodetected"] = "NoBuildCommandAutodetected"; CliConfigErrorCategory["NoBuildCommandAutodetected"] = "NoBuildCommandAutodetected";
@ -128,6 +128,7 @@ var CliConfigErrorCategory;
CliConfigErrorCategory["NoSourceCodeSeen"] = "NoSourceCodeSeen"; CliConfigErrorCategory["NoSourceCodeSeen"] = "NoSourceCodeSeen";
CliConfigErrorCategory["NoSupportedBuildCommandSucceeded"] = "NoSupportedBuildCommandSucceeded"; CliConfigErrorCategory["NoSupportedBuildCommandSucceeded"] = "NoSupportedBuildCommandSucceeded";
CliConfigErrorCategory["NoSupportedBuildSystemDetected"] = "NoSupportedBuildSystemDetected"; CliConfigErrorCategory["NoSupportedBuildSystemDetected"] = "NoSupportedBuildSystemDetected";
CliConfigErrorCategory["OutOfMemoryOrDisk"] = "OutOfMemoryOrDisk";
CliConfigErrorCategory["PackCannotBeFound"] = "PackCannotBeFound"; CliConfigErrorCategory["PackCannotBeFound"] = "PackCannotBeFound";
CliConfigErrorCategory["SwiftBuildFailed"] = "SwiftBuildFailed"; CliConfigErrorCategory["SwiftBuildFailed"] = "SwiftBuildFailed";
CliConfigErrorCategory["UnsupportedBuildMode"] = "UnsupportedBuildMode"; CliConfigErrorCategory["UnsupportedBuildMode"] = "UnsupportedBuildMode";
@ -142,9 +143,6 @@ exports.cliErrorsConfig = {
new RegExp("Failed to clone external Git repository"), new RegExp("Failed to clone external Git repository"),
], ],
}, },
[CliConfigErrorCategory.GracefulOutOfMemory]: {
cliErrorMessageCandidates: [new RegExp("CodeQL is out of memory.")],
},
[CliConfigErrorCategory.GradleBuildFailed]: { [CliConfigErrorCategory.GradleBuildFailed]: {
cliErrorMessageCandidates: [ cliErrorMessageCandidates: [
new RegExp("[autobuild] FAILURE: Build failed with an exception."), new RegExp("[autobuild] FAILURE: Build failed with an exception."),
@ -162,6 +160,12 @@ exports.cliErrorsConfig = {
], ],
additionalErrorMessageToAppend: `Is the "init" action called twice in the same job?`, 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 // Expected source location for database creation does not exist
[CliConfigErrorCategory.InvalidSourceRoot]: { [CliConfigErrorCategory.InvalidSourceRoot]: {
cliErrorMessageCandidates: [new RegExp("Invalid source root")], cliErrorMessageCandidates: [new RegExp("Invalid source root")],
@ -200,6 +204,14 @@ exports.cliErrorsConfig = {
new RegExp("No supported build system detected"), 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]: { [CliConfigErrorCategory.PackCannotBeFound]: {
cliErrorMessageCandidates: [ cliErrorMessageCandidates: [
new RegExp("Query pack .* cannot be found\\. Check the spelling of the pack\\."), new RegExp("Query pack .* cannot be found\\. Check the spelling of the pack\\."),

File diff suppressed because one or more lines are too long

View file

@ -122,10 +122,10 @@ function ensureEndsInPeriod(text: string): string {
/** Error messages from the CLI that we consider configuration errors and handle specially. */ /** Error messages from the CLI that we consider configuration errors and handle specially. */
export enum CliConfigErrorCategory { export enum CliConfigErrorCategory {
ExternalRepositoryCloneFailed = "ExternalRepositoryCloneFailed", ExternalRepositoryCloneFailed = "ExternalRepositoryCloneFailed",
GracefulOutOfMemory = "GracefulOutOfMemory",
GradleBuildFailed = "GradleBuildFailed", GradleBuildFailed = "GradleBuildFailed",
IncompatibleWithActionVersion = "IncompatibleWithActionVersion", IncompatibleWithActionVersion = "IncompatibleWithActionVersion",
InitCalledTwice = "InitCalledTwice", InitCalledTwice = "InitCalledTwice",
InvalidConfigFile = "InvalidConfigFile",
InvalidSourceRoot = "InvalidSourceRoot", InvalidSourceRoot = "InvalidSourceRoot",
MavenBuildFailed = "MavenBuildFailed", MavenBuildFailed = "MavenBuildFailed",
NoBuildCommandAutodetected = "NoBuildCommandAutodetected", NoBuildCommandAutodetected = "NoBuildCommandAutodetected",
@ -133,6 +133,7 @@ export enum CliConfigErrorCategory {
NoSourceCodeSeen = "NoSourceCodeSeen", NoSourceCodeSeen = "NoSourceCodeSeen",
NoSupportedBuildCommandSucceeded = "NoSupportedBuildCommandSucceeded", NoSupportedBuildCommandSucceeded = "NoSupportedBuildCommandSucceeded",
NoSupportedBuildSystemDetected = "NoSupportedBuildSystemDetected", NoSupportedBuildSystemDetected = "NoSupportedBuildSystemDetected",
OutOfMemoryOrDisk = "OutOfMemoryOrDisk",
PackCannotBeFound = "PackCannotBeFound", PackCannotBeFound = "PackCannotBeFound",
SwiftBuildFailed = "SwiftBuildFailed", SwiftBuildFailed = "SwiftBuildFailed",
UnsupportedBuildMode = "UnsupportedBuildMode", UnsupportedBuildMode = "UnsupportedBuildMode",
@ -158,9 +159,6 @@ export const cliErrorsConfig: Record<
new RegExp("Failed to clone external Git repository"), new RegExp("Failed to clone external Git repository"),
], ],
}, },
[CliConfigErrorCategory.GracefulOutOfMemory]: {
cliErrorMessageCandidates: [new RegExp("CodeQL is out of memory.")],
},
[CliConfigErrorCategory.GradleBuildFailed]: { [CliConfigErrorCategory.GradleBuildFailed]: {
cliErrorMessageCandidates: [ cliErrorMessageCandidates: [
new RegExp("[autobuild] FAILURE: Build failed with an exception."), new RegExp("[autobuild] FAILURE: Build failed with an exception."),
@ -180,6 +178,12 @@ export const cliErrorsConfig: Record<
], ],
additionalErrorMessageToAppend: `Is the "init" action called twice in the same job?`, 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 // Expected source location for database creation does not exist
[CliConfigErrorCategory.InvalidSourceRoot]: { [CliConfigErrorCategory.InvalidSourceRoot]: {
cliErrorMessageCandidates: [new RegExp("Invalid source root")], cliErrorMessageCandidates: [new RegExp("Invalid source root")],
@ -214,7 +218,6 @@ export const cliErrorsConfig: Record<
), ),
], ],
}, },
[CliConfigErrorCategory.NoSupportedBuildCommandSucceeded]: { [CliConfigErrorCategory.NoSupportedBuildCommandSucceeded]: {
cliErrorMessageCandidates: [ cliErrorMessageCandidates: [
new RegExp("No supported build command succeeded"), new RegExp("No supported build command succeeded"),
@ -225,6 +228,15 @@ export const cliErrorsConfig: Record<
new RegExp("No supported build system detected"), 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]: { [CliConfigErrorCategory.PackCannotBeFound]: {
cliErrorMessageCandidates: [ cliErrorMessageCandidates: [
new RegExp( new RegExp(