From 996a1d5e6337bbe4dc2b8ba52b0705f5ec5ad4b5 Mon Sep 17 00:00:00 2001 From: Benedikt Schackenberg <6381261+BenediktSchackenberg@users.noreply.github.com> Date: Thu, 19 Mar 2026 20:43:41 +0000 Subject: [PATCH] fix: tighten HTTP status regex to avoid matching longer codes, fix comment to mention 408 exclusion --- src/infra/outbound/delivery-queue.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/infra/outbound/delivery-queue.ts b/src/infra/outbound/delivery-queue.ts index 6af947c1ea1..6003e954526 100644 --- a/src/infra/outbound/delivery-queue.ts +++ b/src/infra/outbound/delivery-queue.ts @@ -442,13 +442,13 @@ const PERMANENT_ERROR_PATTERNS: readonly RegExp[] = [ * Matches HTTP status codes embedded in error strings, e.g. * "status 400", "HTTP 403", "Status code: 413", "status code 400". */ -const HTTP_STATUS_PATTERN = /(?:status(?:\s+code)?:?\s*|HTTP\/?\s*)(\d{3})/i; +const HTTP_STATUS_PATTERN = /(?:status(?:\s+code)?:?\s*|HTTP\/?\s*)(\d{3})(?!\d)/i; export function isPermanentDeliveryError(error: string): boolean { if (PERMANENT_ERROR_PATTERNS.some((re) => re.test(error))) { return true; } - // Detect HTTP 4xx client errors (permanent), except 429 (rate limit). + // Detect HTTP 4xx client errors (permanent), except 408 (timeout) and 429 (rate limit). const statusMatch = HTTP_STATUS_PATTERN.exec(error); if (statusMatch) { const status = parseInt(statusMatch[1], 10);