Skip to content

Commit

Permalink
refactor: increase regex validation debugging (#26244)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Dec 12, 2023
1 parent eeb1024 commit 1fd0c5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/config/validation.ts
@@ -1,4 +1,5 @@
import is from '@sindresorhus/is';
import { logger } from '../logger';
import { allManagersList, getManagerList } from '../modules/manager';
import { isCustomManager } from '../modules/manager/custom';
import type {
Expand Down Expand Up @@ -667,7 +668,11 @@ function validateRegexManagerFields(
for (const matchString of customManager.matchStrings) {
try {
regEx(matchString);
} catch (e) {
} catch (err) {
logger.debug(
{ err },
'customManager.matchStrings regEx validation error',
);
errors.push({
topic: 'Configuration Error',
message: `Invalid regExp for ${currentPath}: \`${matchString}\``,
Expand Down
4 changes: 3 additions & 1 deletion lib/util/regex.ts
Expand Up @@ -49,9 +49,11 @@ export function regEx(
}
return instance;
} catch (err) {
logger.trace({ err }, 'RegEx constructor error');
const error = new Error(CONFIG_VALIDATION);
error.validationMessage = err.message;
error.validationSource = pattern.toString();
error.validationError = `Invalid regular expression: ${pattern.toString()}`;
error.validationError = `Invalid regular expression (re2): ${pattern.toString()}`;
throw error;
}
}
Expand Down

0 comments on commit 1fd0c5c

Please sign in to comment.