Skip to content

Commit

Permalink
refactor: increase regex validation debugging (renovatebot#26244)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins authored and hersentino committed Jan 9, 2024
1 parent 638f5be commit b09bcff
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 b09bcff

Please sign in to comment.