From 1fd0c5cb4d9ed5d9f06f953a168c2d027b563e8a Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Tue, 12 Dec 2023 09:48:22 +0100 Subject: [PATCH] refactor: increase regex validation debugging (#26244) --- lib/config/validation.ts | 7 ++++++- lib/util/regex.ts | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/config/validation.ts b/lib/config/validation.ts index 7e928b23b66b5e..d83a0694cedf68 100644 --- a/lib/config/validation.ts +++ b/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 { @@ -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}\``, diff --git a/lib/util/regex.ts b/lib/util/regex.ts index 64630d0f3cf671..60289ad1ee8643 100644 --- a/lib/util/regex.ts +++ b/lib/util/regex.ts @@ -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; } }