Skip to content

Commit d20753c

Browse files
czlonkowskiclaude
andcommitted
fix: replace the NO_RESPONSE detail regex with a string scan
CodeQL flagged /\(([^)]+)\)\s*$/ as polynomially backtracking on '('-heavy input. Scan for the parenthesized suffix with lastIndexOf instead; same accepted shape. Conceived by Romuald Członkowski - www.aiadvisors.pl/en Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent cbdf4b6 commit d20753c

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
## [Unreleased]
11-
1210
## [2.71.0] - 2026-08-18
1311

1412
### Fixed

src/utils/n8n-errors.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,16 @@ export function getUserFriendlyErrorMessage(error: N8nApiError): string {
207207
// message (e.g. "(ECONNREFUSED 127.0.0.1:5678)") when present, so the
208208
// generic sentence doesn't hide which address actually failed.
209209
const generic = 'Unable to connect to n8n. Please check the server URL and ensure n8n is running.';
210-
const detailMatch = error.message.match(/\(([^)]+)\)\s*$/);
211-
return detailMatch ? `${generic} (${detailMatch[1]})` : generic;
210+
// Plain string scan instead of a trailing-group regex (CodeQL
211+
// js/polynomial-redos): take a non-empty parenthesized suffix that
212+
// contains no nested parens, which is the only shape
213+
// describeConnectionFailure produces.
214+
const message = error.message.trimEnd();
215+
const open = message.lastIndexOf('(');
216+
const detail = message.endsWith(')') && open !== -1
217+
? message.slice(open + 1, -1)
218+
: '';
219+
return detail && !detail.includes(')') ? `${generic} (${detail})` : generic;
212220
}
213221
case 'SERVER_ERROR':
214222
// For server errors, we should not show generic message

0 commit comments

Comments
 (0)