Skip to content

Commit 781a65a

Browse files
committed
Use appropriate error message in parseQueriesFromInput for repo property input
1 parent ed216a0 commit 781a65a

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

lib/init-action.js

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

src/config/db-config.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,16 @@ export async function calculateAugmentation(
313313
const repoExtraQueriesCombines = shouldCombine(repoExtraQueries);
314314
const repoPropertyQueries = {
315315
combines: repoExtraQueriesCombines,
316-
input: parseQueriesFromInput(repoExtraQueries, repoExtraQueriesCombines),
316+
input: parseQueriesFromInput(
317+
repoExtraQueries,
318+
repoExtraQueriesCombines,
319+
new ConfigurationError(
320+
errorMessages.getRepoPropertyError(
321+
RepositoryPropertyName.EXTRA_QUERIES,
322+
errorMessages.getEmptyCombinesError(),
323+
),
324+
),
325+
),
317326
};
318327

319328
return {
@@ -328,6 +337,7 @@ export async function calculateAugmentation(
328337
function parseQueriesFromInput(
329338
rawQueriesInput: string | undefined,
330339
queriesInputCombines: boolean,
340+
errorToThrow?: ConfigurationError,
331341
) {
332342
if (!rawQueriesInput) {
333343
return undefined;
@@ -337,6 +347,9 @@ function parseQueriesFromInput(
337347
? rawQueriesInput.trim().slice(1).trim()
338348
: (rawQueriesInput?.trim() ?? "");
339349
if (queriesInputCombines && trimmedInput.length === 0) {
350+
if (errorToThrow) {
351+
throw errorToThrow;
352+
}
340353
throw new ConfigurationError(
341354
errorMessages.getConfigFilePropertyError(
342355
undefined,

src/error-messages.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { RepositoryPropertyName } from "./feature-flags/properties";
2+
13
const PACKS_PROPERTY = "packs";
24

35
export function getConfigFileOutsideWorkspaceErrorMessage(
@@ -29,6 +31,10 @@ export function getConfigFileDirectoryGivenMessage(configFile: string): string {
2931
return `The configuration file "${configFile}" looks like a directory, not a file`;
3032
}
3133

34+
export function getEmptyCombinesError(): string {
35+
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.`;
36+
}
37+
3238
export function getConfigFilePropertyError(
3339
configFile: string | undefined,
3440
property: string,
@@ -41,6 +47,13 @@ export function getConfigFilePropertyError(
4147
}
4248
}
4349

50+
export function getRepoPropertyError(
51+
propertyName: RepositoryPropertyName,
52+
error: string,
53+
): string {
54+
return `The repository property "${propertyName}" is invalid: ${error}`;
55+
}
56+
4457
export function getPacksStrInvalid(
4558
packStr: string,
4659
configFile?: string,

0 commit comments

Comments
 (0)