{"record":{"id":"21a48b6a1787b2ba","repo":"diegosouzapw/OmniRoute","slug":"pii-blocked-response-due-to-sanitization-failure","errorCode":null,"errorMessage":"[PII] Blocked response due to sanitization failure","messagePattern":"\\[PII\\] Blocked response due to sanitization failure","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/piiSanitizer.ts","lineNumber":341,"sourceCode":"      }\n      return obj;\n    };\n\n    return deepSanitize(response);\n  } catch (err: any) {\n    if (err?.message?.startsWith(\"[PII] Blocked response\")) {\n      throw err;\n    }\n    // Fail secure — try raw string sanitization instead of failing open\n    try {\n      const serialized = JSON.stringify(response);\n      const { text: sanitized } = sanitizePII(serialized);\n      return JSON.parse(sanitized);\n    } catch (fallbackErr) {\n      // Suppress err.message — never surface upstream error detail to the client\n      // (Hard Rule #12). The underlying error is available in server logs.\n      console.warn(\"[PII] Sanitization fallback failed:\", err?.message);\n      throw new Error(\"[PII] Blocked response due to sanitization failure\");\n    }\n  }\n}\n\n// ── Checksum Validation Helpers ──\n\nfunction isValidLuhn(digits: string): boolean {\n  let sum = 0;\n  let shouldDouble = false;\n  for (let i = digits.length - 1; i >= 0; i--) {\n    let digit = parseInt(digits[i], 10);\n    if (shouldDouble) {\n      digit *= 2;\n      if (digit > 9) digit -= 9;\n    }\n    sum += digit;\n    shouldDouble = !shouldDouble;\n  }","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/piiSanitizer.ts#L323-L359","documentation":"Error \"[PII] Blocked response due to sanitization failure\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/piiSanitizer.ts:341 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"}