fix: fix issue where wrapApiConfigurationError would fail to regex match a string due to boundary constraints on the regex

This commit is contained in:
Fotis Koutoulakis (@NlightNFotis) 2025-03-28 14:32:53 +00:00
parent 2be6da694a
commit 73c938dbc0
6 changed files with 10 additions and 6 deletions

View file

@ -122,6 +122,8 @@ test("wrapApiConfigurationError correctly wraps specific configuration errors",
res = api.wrapApiConfigurationError(httpError);
t.is(res, httpError);
// For other HTTP errors, we wrap them as Configuration errors if they contain
// specific error messages.
const httpNotFoundError = new util.HTTPError("commit not found", 404);
res = api.wrapApiConfigurationError(httpNotFoundError);
t.deepEqual(res, new util.ConfigurationError("commit not found"));
@ -134,7 +136,7 @@ test("wrapApiConfigurationError correctly wraps specific configuration errors",
t.deepEqual(
res,
new util.ConfigurationError(
"ref 'refs/heads/jitsi' not found in this repository",
"ref 'refs/heads/jitsi' not found in this repository - https://docs.github.com/rest",
),
);

View file

@ -245,7 +245,7 @@ export function wrapApiConfigurationError(e: unknown) {
if (
e.message.includes("API rate limit exceeded for installation") ||
e.message.includes("commit not found") ||
/^ref .* not found in this repository$/.test(e.message)
/ref .* not found in this repository/.test(e.message)
) {
return new ConfigurationError(e.message);
}