mirror of
https://github.com/github/codeql-action.git
synced 2026-10-30 01:27:22 +00:00
Use appropriate error message in parseQueriesFromInput for repo property input
This commit is contained in:
@@ -313,7 +313,16 @@ export async function calculateAugmentation(
|
||||
const repoExtraQueriesCombines = shouldCombine(repoExtraQueries);
|
||||
const repoPropertyQueries = {
|
||||
combines: repoExtraQueriesCombines,
|
||||
input: parseQueriesFromInput(repoExtraQueries, repoExtraQueriesCombines),
|
||||
input: parseQueriesFromInput(
|
||||
repoExtraQueries,
|
||||
repoExtraQueriesCombines,
|
||||
new ConfigurationError(
|
||||
errorMessages.getRepoPropertyError(
|
||||
RepositoryPropertyName.EXTRA_QUERIES,
|
||||
errorMessages.getEmptyCombinesError(),
|
||||
),
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -328,6 +337,7 @@ export async function calculateAugmentation(
|
||||
function parseQueriesFromInput(
|
||||
rawQueriesInput: string | undefined,
|
||||
queriesInputCombines: boolean,
|
||||
errorToThrow?: ConfigurationError,
|
||||
) {
|
||||
if (!rawQueriesInput) {
|
||||
return undefined;
|
||||
@@ -337,6 +347,9 @@ function parseQueriesFromInput(
|
||||
? rawQueriesInput.trim().slice(1).trim()
|
||||
: (rawQueriesInput?.trim() ?? "");
|
||||
if (queriesInputCombines && trimmedInput.length === 0) {
|
||||
if (errorToThrow) {
|
||||
throw errorToThrow;
|
||||
}
|
||||
throw new ConfigurationError(
|
||||
errorMessages.getConfigFilePropertyError(
|
||||
undefined,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { RepositoryPropertyName } from "./feature-flags/properties";
|
||||
|
||||
const PACKS_PROPERTY = "packs";
|
||||
|
||||
export function getConfigFileOutsideWorkspaceErrorMessage(
|
||||
@@ -29,6 +31,10 @@ export function getConfigFileDirectoryGivenMessage(configFile: string): string {
|
||||
return `The configuration file "${configFile}" looks like a directory, not a file`;
|
||||
}
|
||||
|
||||
export function getEmptyCombinesError(): string {
|
||||
return `A '+' was used to specify that you want to add extra arguments to the configuration, but no extra arguments were specified. Please either remove the '+' or specify some extra arguments.`;
|
||||
}
|
||||
|
||||
export function getConfigFilePropertyError(
|
||||
configFile: string | undefined,
|
||||
property: string,
|
||||
@@ -41,6 +47,13 @@ export function getConfigFilePropertyError(
|
||||
}
|
||||
}
|
||||
|
||||
export function getRepoPropertyError(
|
||||
propertyName: RepositoryPropertyName,
|
||||
error: string,
|
||||
): string {
|
||||
return `The repository property "${propertyName}" is invalid: ${error}`;
|
||||
}
|
||||
|
||||
export function getPacksStrInvalid(
|
||||
packStr: string,
|
||||
configFile?: string,
|
||||
|
||||
Reference in New Issue
Block a user