diff --git a/lib/config/presets/index.spec.ts b/lib/config/presets/index.spec.ts index 838c6b528749d26af76fad3e4f4e9b25eb702d37..763cf30f19335e4d8b6c463ab39db24d9e8bde1c 100644 --- a/lib/config/presets/index.spec.ts +++ b/lib/config/presets/index.spec.ts @@ -62,7 +62,7 @@ describe(getName(), () => { e = err; } expect(e).toBeDefined(); - expect(e.location).toMatchSnapshot(); + expect(e.validationSource).toMatchSnapshot(); expect(e.validationError).toMatchSnapshot(); expect(e.validationMessage).toMatchSnapshot(); }); @@ -76,7 +76,7 @@ describe(getName(), () => { e = err; } expect(e).toBeDefined(); - expect(e.location).toMatchSnapshot(); + expect(e.validationSource).toMatchSnapshot(); expect(e.validationError).toMatchSnapshot(); expect(e.validationMessage).toMatchSnapshot(); }); @@ -91,7 +91,7 @@ describe(getName(), () => { e = err; } expect(e).toBeDefined(); - expect(e.location).toMatchSnapshot(); + expect(e.validationSource).toMatchSnapshot(); expect(e.validationError).toMatchSnapshot(); expect(e.validationMessage).toMatchSnapshot(); }); @@ -106,7 +106,7 @@ describe(getName(), () => { e = err; } expect(e).toBeDefined(); - expect(e.location).toMatchSnapshot(); + expect(e.validationSource).toMatchSnapshot(); expect(e.validationError).toMatchSnapshot(); expect(e.validationMessage).toMatchSnapshot(); }); @@ -121,7 +121,7 @@ describe(getName(), () => { e = err; } expect(e).toBeDefined(); - expect(e.location).toMatchSnapshot(); + expect(e.validationSource).toMatchSnapshot(); expect(e.validationError).toMatchSnapshot(); expect(e.validationMessage).toMatchSnapshot(); }); @@ -136,7 +136,7 @@ describe(getName(), () => { e = err; } expect(e).toBeDefined(); - expect(e.location).toMatchSnapshot(); + expect(e.validationSource).toMatchSnapshot(); expect(e.validationError).toMatchSnapshot(); expect(e.validationMessage).toMatchSnapshot(); }); @@ -159,7 +159,7 @@ describe(getName(), () => { e = err; } expect(e).toBeDefined(); - expect(e.location).toMatchSnapshot(); + expect(e.validationSource).toMatchSnapshot(); expect(e.validationError).toMatchSnapshot(); expect(e.validationMessage).toMatchSnapshot(); }); @@ -430,7 +430,7 @@ describe(getName(), () => { e = err; } expect(e).toBeDefined(); - expect(e.location).toMatchSnapshot(); + expect(e.validationSource).toMatchSnapshot(); expect(e.validationError).toMatchSnapshot(); expect(e.validationMessage).toMatchSnapshot(); }); @@ -442,7 +442,7 @@ describe(getName(), () => { e = err; } expect(e).toBeDefined(); - expect(e.location).toMatchSnapshot(); + expect(e.validationSource).toMatchSnapshot(); expect(e.validationError).toMatchSnapshot(); expect(e.validationMessage).toMatchSnapshot(); }); @@ -454,7 +454,7 @@ describe(getName(), () => { e = err; } expect(e).toBeDefined(); - expect(e.location).toMatchSnapshot(); + expect(e.validationSource).toMatchSnapshot(); expect(e.validationError).toMatchSnapshot(); expect(e.validationMessage).toMatchSnapshot(); }); @@ -466,7 +466,7 @@ describe(getName(), () => { e = err; } expect(e).toBeDefined(); - expect(e.location).toMatchSnapshot(); + expect(e.validationSource).toMatchSnapshot(); expect(e.validationError).toMatchSnapshot(); expect(e.validationMessage).toMatchSnapshot(); }); diff --git a/lib/config/secrets.ts b/lib/config/secrets.ts index 97fbb6c9c3439cacdbf41445a073c560ee193275..c07a0fc912cab3d31d81c71406ca214c98d3a9c0 100644 --- a/lib/config/secrets.ts +++ b/lib/config/secrets.ts @@ -64,7 +64,7 @@ function replaceSecretsInString( const disallowedPrefixes = ['branch', 'commit', 'group', 'pr', 'semantic']; if (disallowedPrefixes.some((prefix) => key.startsWith(prefix))) { const error = new Error(CONFIG_VALIDATION); - error.location = 'config'; + error.validationSource = 'config'; error.validationError = 'Disallowed secret substitution'; error.validationMessage = `The field ${key} may not use secret substitution`; throw error; @@ -74,7 +74,7 @@ function replaceSecretsInString( return secrets[secretName]; } const error = new Error(CONFIG_VALIDATION); - error.location = 'config'; + error.validationSource = 'config'; error.validationError = 'Unknown secret name'; error.validationMessage = `The following secret name was not found in config: ${String( secretName diff --git a/lib/globals.d.ts b/lib/globals.d.ts index 6edf0241f13c35cea23ff945c9985ed565297c64..eef15fbf1826df8aed78f800a647a58527745637 100644 --- a/lib/globals.d.ts +++ b/lib/globals.d.ts @@ -3,7 +3,7 @@ */ declare interface Error { - location?: string; + validationSource?: string; validationError?: string; validationMessage?: string; diff --git a/lib/manager/npm/extract/index.ts b/lib/manager/npm/extract/index.ts index 7521b692ec72109b3f0c78cc7fdf993fbd28c354..472c8d07811d835ad76861cf30374fac58771783 100644 --- a/lib/manager/npm/extract/index.ts +++ b/lib/manager/npm/extract/index.ts @@ -51,7 +51,7 @@ export async function extractPackageFile( } if (fileName !== 'package.json' && packageJson.renovate) { const error = new Error(CONFIG_VALIDATION); - error.location = fileName; + error.validationSource = fileName; error.validationError = 'Nested package.json must not contain renovate configuration. Please use `packageRules` with `matchPaths` in your main config instead.'; throw error; diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts index bb74bb58b2f13b571a12251b92690dde115c21ff..db1a25825e372b8938c403744d604d19562eddb3 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -774,7 +774,7 @@ export async function commitFiles({ checkForPlatformFailure(err); if (err.message.includes(`'refs/heads/renovate' exists`)) { const error = new Error(CONFIG_VALIDATION); - error.location = 'None'; + error.validationSource = 'None'; error.validationError = 'An existing branch is blocking Renovate'; error.validationMessage = `Renovate needs to create the branch "${branchName}" but is blocked from doing so because of an existing branch called "renovate". Please remove it so that Renovate can proceed.`; throw error; @@ -800,7 +800,7 @@ export async function commitFiles({ } if (err.message.includes('protected branch hook declined')) { const error = new Error(CONFIG_VALIDATION); - error.location = branchName; + error.validationSource = branchName; error.validationError = 'Renovate branch is protected'; error.validationMessage = `Renovate cannot push to its branch because branch protection has been enabled.`; throw error; diff --git a/lib/util/regex.ts b/lib/util/regex.ts index c376caae7d94f75cd9273a143011a7766bcc903c..1ece8cf47c4d6cb30a6a02f2943c289de4ca8c4d 100644 --- a/lib/util/regex.ts +++ b/lib/util/regex.ts @@ -21,7 +21,7 @@ export function regEx(pattern: string, flags?: string): RegExp { return new RegEx(pattern, flags); } catch (err) { const error = new Error(CONFIG_VALIDATION); - error.location = pattern; + error.validationSource = pattern; error.validationError = `Invalid regular expression: ${pattern}`; throw error; } diff --git a/lib/versioning/regex/index.ts b/lib/versioning/regex/index.ts index e0cedd1c11aaefb309bb387731de3c66256ab2bd..9257a41d0a09851338a7d3f68dc5dcdfa67fc3f9 100644 --- a/lib/versioning/regex/index.ts +++ b/lib/versioning/regex/index.ts @@ -55,7 +55,7 @@ export class RegExpVersioningApi extends GenericVersioningApi<RegExpVersion> { !new_config.includes('<patch>') ) { const error = new Error(CONFIG_VALIDATION); - error.location = new_config; + error.validationSource = new_config; error.validationError = 'regex versioning needs at least one major, minor or patch group defined'; throw error; diff --git a/lib/workers/repository/error-config.spec.ts b/lib/workers/repository/error-config.spec.ts index f0df8e445ad8145a53c8352a4eb4646c2ec8e679..5e7f6b8475c211bd8baf9a1f29bc887782630678 100644 --- a/lib/workers/repository/error-config.spec.ts +++ b/lib/workers/repository/error-config.spec.ts @@ -26,7 +26,7 @@ describe(getName(), () => { }); it('creates issues', async () => { const error = new Error(CONFIG_VALIDATION); - error.location = 'package.json'; + error.validationSource = 'package.json'; error.validationMessage = 'some-message'; platform.ensureIssue.mockResolvedValueOnce('created'); const res = await raiseConfigWarningIssue(config, error); @@ -34,7 +34,7 @@ describe(getName(), () => { }); it('creates issues (dryRun)', async () => { const error = new Error(CONFIG_VALIDATION); - error.location = 'package.json'; + error.validationSource = 'package.json'; error.validationMessage = 'some-message'; platform.ensureIssue.mockResolvedValueOnce('created'); setAdminConfig({ dryRun: true }); @@ -43,7 +43,7 @@ describe(getName(), () => { }); it('handles onboarding', async () => { const error = new Error(CONFIG_VALIDATION); - error.location = 'package.json'; + error.validationSource = 'package.json'; error.validationMessage = 'some-message'; platform.getBranchPr.mockResolvedValue({ ...mock<Pr>(), @@ -55,7 +55,7 @@ describe(getName(), () => { }); it('handles onboarding (dryRun)', async () => { const error = new Error(CONFIG_VALIDATION); - error.location = 'package.json'; + error.validationSource = 'package.json'; error.validationMessage = 'some-message'; platform.getBranchPr.mockResolvedValue({ ...mock<Pr>(), diff --git a/lib/workers/repository/error-config.ts b/lib/workers/repository/error-config.ts index f26bfb41876a7b8d9b12510087b73796624f2c26..8b12091fb1540e6246f8c276d11def9da010db2c 100644 --- a/lib/workers/repository/error-config.ts +++ b/lib/workers/repository/error-config.ts @@ -10,8 +10,8 @@ export async function raiseConfigWarningIssue( ): Promise<void> { logger.debug('raiseConfigWarningIssue()'); let body = `There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.\n\n`; - if (error.location) { - body += `Location: \`${error.location}\`\n`; + if (error.validationSource) { + body += `Location: \`${error.validationSource}\`\n`; } body += `Error type: ${error.validationError}\n`; if (error.validationMessage) { diff --git a/lib/workers/repository/init/merge.ts b/lib/workers/repository/init/merge.ts index 8529f45f39ac98c158e236f76242ebefd45bfda3..95cb880088909dcec879dc0e8dd4146e0acf894c 100644 --- a/lib/workers/repository/init/merge.ts +++ b/lib/workers/repository/init/merge.ts @@ -136,7 +136,7 @@ export function checkForRepoConfigError(repoConfig: RepoFileConfig): void { return; } const error = new Error(CONFIG_VALIDATION); - error.location = repoConfig.configFileName; + error.validationSource = repoConfig.configFileName; error.validationError = repoConfig.configFileParseError.validationError; error.validationMessage = repoConfig.configFileParseError.validationMessage; throw error; @@ -160,7 +160,7 @@ export async function mergeRenovateConfig( const migratedConfig = await migrateAndValidate(config, configFileParsed); if (migratedConfig.errors.length) { const error = new Error(CONFIG_VALIDATION); - error.location = repoConfig.configFileName; + error.validationSource = repoConfig.configFileName; error.validationError = 'The renovate configuration file contains some invalid settings'; error.validationMessage = migratedConfig.errors diff --git a/lib/workers/repository/process/lookup/filter.ts b/lib/workers/repository/process/lookup/filter.ts index bfe7f996a9e8874ab0e852a910f46d2779655af9..f3331df1be33a7b967d39d9d846023bf13fbd198 100644 --- a/lib/workers/repository/process/lookup/filter.ts +++ b/lib/workers/repository/process/lookup/filter.ts @@ -98,7 +98,7 @@ export function filterVersions( ); } else { const error = new Error(CONFIG_VALIDATION); - error.location = 'config'; + error.validationSource = 'config'; error.validationError = 'Invalid `allowedVersions`'; error.validationMessage = 'The following allowedVersions does not parse as a valid version or range: ' +