From 8bed101303fe20fb4d604a95bc783ab39aebe36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Kopyci=C5=84ski?= Date: Sun, 30 Aug 2026 10:27:47 +0200 Subject: [PATCH] fix(guardrails): prevent duplicate prompt-injection-guard log output (#11936) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Boarded with 8 other PRs in one combined worktree: typecheck:core, check:file-size, check:changelog-integrity, check:complexity, check:cognitive-complexity, check:cycles, check-native-deps all green; 75/75 focused tests pass. Verified the console fallback → null fix removes the duplicate plain-text line while the structured pino log is unaffected. Thanks. --- src/lib/guardrails/promptInjection.ts | 2 +- src/middleware/promptInjectionGuard.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/guardrails/promptInjection.ts b/src/lib/guardrails/promptInjection.ts index eed2d21709..b2ca2030b1 100644 --- a/src/lib/guardrails/promptInjection.ts +++ b/src/lib/guardrails/promptInjection.ts @@ -111,7 +111,7 @@ function shouldBlock(detections: Detection[], threshold: "low" | "medium" | "hig } function getLogger(options: PromptInjectionGuardrailOptions, context: GuardrailContext) { - return options.logger || context.log || console; + return options.logger ?? context.log ?? null; } function emitGuardrailLog( diff --git a/src/middleware/promptInjectionGuard.ts b/src/middleware/promptInjectionGuard.ts index be2e149479..727e005c89 100644 --- a/src/middleware/promptInjectionGuard.ts +++ b/src/middleware/promptInjectionGuard.ts @@ -33,7 +33,7 @@ export function createInjectionGuard(options: PromptInjectionGuardrailOptions = const decision = evaluatePromptInjection(body, options, { disabledGuardrails: resolveDisabledGuardrails({ body }), - log: options.logger || console, + log: options.logger ?? null, }); return { blocked: decision.blocked,