From 205ee1dd2e28314f1f1ccb43681afc5ebab53343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 15 May 2026 17:26:12 +0200 Subject: [PATCH] chore(api): surface every safeRequestProp fallback through a console warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The W7d narrowing already pinned the catch to the V8 private-field TypeError shape, but a real read regression — say, a header parser crashing on a malformed value — still slipped through silently into the fallback path because the narrow-catch swallowed every tolerated error without trace. Logs every fallback through console.warn in non-test environments so the dev console and run log surface a regression while the production path keeps the same defensive defaults. The /api/insights/targets stray-brace comment typo and the BASE_SYSTEM_PROMPT / INSIGHTS_SYSTEM_PROMPT bare exports flagged by the original BL-P1-2 / BL-P1-4 items were already retired earlier in the v1.4.27 cycle. --- src/lib/api-handler.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/api-handler.ts b/src/lib/api-handler.ts index cf36d5271..b9afbc02b 100644 --- a/src/lib/api-handler.ts +++ b/src/lib/api-handler.ts @@ -78,7 +78,20 @@ function safeRequestProp( try { return read(request as NextRequest); } catch (err) { - if (isTolerableRequestProbeError(err)) return fallback; + if (isTolerableRequestProbeError(err)) { + // v1.4.27 B7 / BL-P1-3 — surface every fallback so a real read + // regression cannot hide behind the tolerated-error narrowing. + // Vitest direct-invoke and the force-static placeholder path are + // the two known-quiet shapes; anything else worth a look should + // show up in the dev console + the run log. + if (process.env.NODE_ENV !== "test") { + const msg = err instanceof Error ? err.message : String(err); + console.warn( + `[api-handler] safeRequestProp fallback — tolerable error: ${msg}`, + ); + } + return fallback; + } throw err; } }