diegosouzapw/OmniRoute · error

[PII] Blocked response due to sanitization failure

Error message

[PII] Blocked response due to sanitization failure

What it means

sanitizePIIResponse fail-secure path: normal deep sanitization threw an unexpected error, and the JSON.stringify fallback also failed. Rather than returning unsanitized data (fail-open), the function throws a generic '[PII] Blocked response due to sanitization failure'. The underlying error stays in server logs only.

Solutions

  1. Inspect server logs for the fallbackErr to find why both passes failed
  2. Check the response payload for structures that break JSON.stringify (cycles, BigInt)
  3. Retry the request — transient failures may not recur
  4. Temporarily disable PII response sanitization if the payload is trusted
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/lib/piiSanitizer.ts:341 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/21a48b6a1787b2ba. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/piiSanitizer.ts:341

      }
      return obj;
    };

    return deepSanitize(response);
  } catch (err: any) {
    if (err?.message?.startsWith("[PII] Blocked response")) {
      throw err;
    }
    // Fail secure — try raw string sanitization instead of failing open
    try {
      const serialized = JSON.stringify(response);
      const { text: sanitized } = sanitizePII(serialized);
      return JSON.parse(sanitized);
    } catch (fallbackErr) {
      // Suppress err.message — never surface upstream error detail to the client
      // (Hard Rule #12). The underlying error is available in server logs.
      console.warn("[PII] Sanitization fallback failed:", err?.message);
      throw new Error("[PII] Blocked response due to sanitization failure");
    }
  }
}

// ── Checksum Validation Helpers ──

function isValidLuhn(digits: string): boolean {
  let sum = 0;
  let shouldDouble = false;
  for (let i = digits.length - 1; i >= 0; i--) {
    let digit = parseInt(digits[i], 10);
    if (shouldDouble) {
      digit *= 2;
      if (digit > 9) digit -= 9;
    }
    sum += digit;
    shouldDouble = !shouldDouble;
  }

View on GitHub (pinned to a179ffed5b)