Skip to content

Commit

Permalink
Merge pull request #2786 from github/henrymercer/more-config-errors
Browse files Browse the repository at this point in the history
Add some more configuration errors
  • Loading branch information
henrymercer authored Mar 3, 2025
2 parents 8392354 + d59d0eb commit 2db5b5a
Showing 6 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 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.

6 changes: 5 additions & 1 deletion lib/codeql.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/codeql.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/cli-errors.ts
Original file line number Diff line number Diff line change
@@ -119,6 +119,7 @@ function extractAutobuildErrors(error: string): string | undefined {
/** Error messages from the CLI that we consider configuration errors and handle specially. */
export enum CliConfigErrorCategory {
AutobuildError = "AutobuildError",
CouldNotCreateTempDir = "CouldNotCreateTempDir",
ExternalRepositoryCloneFailed = "ExternalRepositoryCloneFailed",
GradleBuildFailed = "GradleBuildFailed",
IncompatibleWithActionVersion = "IncompatibleWithActionVersion",
@@ -159,6 +160,9 @@ export const cliErrorsConfig: Record<
new RegExp("We were unable to automatically build your code"),
],
},
[CliConfigErrorCategory.CouldNotCreateTempDir]: {
cliErrorMessageCandidates: [new RegExp("Could not create temp directory")],
},
[CliConfigErrorCategory.ExternalRepositoryCloneFailed]: {
cliErrorMessageCandidates: [
new RegExp("Failed to clone external Git repository"),
8 changes: 7 additions & 1 deletion src/codeql.ts
Original file line number Diff line number Diff line change
@@ -377,7 +377,13 @@ export async function setupCodeQL(
zstdAvailability,
};
} catch (e) {
throw new Error(
const ErrorClass =
e instanceof util.ConfigurationError ||
(e instanceof Error && e.message.includes("ENOSPC")) // out of disk space
? util.ConfigurationError
: Error;

throw new ErrorClass(
`Unable to download and extract CodeQL CLI: ${getErrorMessage(e)}${
e instanceof Error && e.stack ? `\n\nDetails: ${e.stack}` : ""
}`,

0 comments on commit 2db5b5a

Please sign in to comment.