{"record":{"id":"7b140e11e18219aa","repo":"diegosouzapw/OmniRoute","slug":"pii-blocked-response-due-to-pii-detection","errorCode":null,"errorMessage":"[PII] Blocked response due to PII detection","messagePattern":"\\[PII\\] Blocked response due to PII detection","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/piiSanitizer.ts","lineNumber":239,"sourceCode":"      pattern: name,\n      count,\n      severity: patternDef?.severity || \"medium\",\n    });\n  }\n\n  if (detections.length > 0) {\n    if (mode === \"warn\") {\n      console.warn(\n        `[PII] Detected PII in response: ${detections.map((d) => `${d.pattern}(${d.count})`).join(\", \")}`\n      );\n    } else if (mode === \"block\") {\n      // Log the matched pattern types server-side, but never put them in the\n      // thrown message — it can surface to the client via controller.error\n      // (Hard Rule #12: no internal detail in response/stream errors).\n      console.warn(\n        `[PII] Blocked response due to PII detection: ${detections.map((d) => d.pattern).join(\", \")}`\n      );\n      throw new Error(\"[PII] Blocked response due to PII detection\");\n    }\n  }\n\n  let sanitized = text;\n  if (mode === \"redact\" && ranges.length > 0) {\n    // Sort ranges from right to left to avoid shifting offsets\n    ranges.sort((a, b) => b.start - a.start);\n\n    // Merge overlapping or adjacent ranges\n    const mergedRanges: typeof ranges = [];\n    for (const r of ranges) {\n      if (mergedRanges.length === 0) {\n        mergedRanges.push(r);\n      } else {\n        const last = mergedRanges[mergedRanges.length - 1];\n        if (r.end >= last.start) {\n          last.start = Math.min(r.start, last.start);\n          last.end = Math.max(r.end, last.end);","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/piiSanitizer.ts#L221-L257","documentation":"Error \"[PII] Blocked response due to PII detection\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/piiSanitizer.ts:239 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}