{"record":{"id":"566a33f675460387","repo":"BerriAI/litellm","slug":"sensitive-data-detected-by-self-guardrail-name-566a33","errorCode":null,"errorMessage":"Sensitive data detected by {self.guardrail_name}","messagePattern":"Sensitive data detected by (.+?)","errorType":"exception","errorClass":"GuardrailRaisedException","httpStatus":null,"severity":"error","filePath":"litellm/integrations/custom_guardrail.py","lineNumber":431,"sourceCode":"            GuardrailRaisedException: When configured to block, or when routing is\n                configured but no session_id is available\n        \"\"\"\n        if self.should_route_on_sensitive_data():\n            try:\n                self.raise_sensitive_data_route_exception(\n                    route_to_model=self.sensitive_data_route_to_model,\n                    request_data=request_data,\n                    detection_info=detection_info,\n                )\n            except ValueError:\n                raise GuardrailRaisedException(\n                    message=(\n                        f\"Sensitive data detected by {self.guardrail_name} (routing skipped: request has no session_id)\"\n                    ),\n                    guardrail_name=self.guardrail_name,\n                )\n        else:\n            raise GuardrailRaisedException(\n                message=f\"Sensitive data detected by {self.guardrail_name}\",\n                guardrail_name=self.guardrail_name,\n            )\n\n    @staticmethod\n    def get_config_model() -> type[\"GuardrailConfigModel\"] | None:\n        \"\"\"\n        Returns the config model for the guardrail\n\n        This is used to render the config model in the UI.\n        \"\"\"\n        return None\n\n    @classmethod\n    def get_supported_event_hooks(cls) -> list[GuardrailEventHooks] | None:\n        \"\"\"\n        Returns the event hooks this guardrail supports, for the UI to render.\n","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/custom_guardrail.py#L413-L449","documentation":"This GuardrailRaisedException is the guardrail doing its job in block mode: sensitive data matched a detection rule, the guardrail is not configured to reroute (should_route_on_sensitive_data() is false), so the call is aborted with 'Sensitive data detected by <guardrail_name>'. The exception propagates out of the guardrail hook and the request never reaches the provider unless caught or excluded.","triggerScenarios":"A guardrail without sensitive_data_route_to_model (mask/route not enabled) runs on a request whose prompt or messages contain a matched entity (e.g. Presidio PII, bedrock guardrail, regex custom guardrail) and detection returns true. Happens on pre_call/during_call hooks depending on the guardrail's event_hook config.","commonSituations":"PII blocking enabled company-wide and users pasting SSNs/emails/credit-card numbers; custom guardrails whose detect() is too broad (blocking benign inputs); testing guardrail configs with the same prompt used to test detection.","solutions":["Remove or redact the sensitive content from the prompt before sending it","If masking is preferred over blocking, enable mask mode (e.g. pii_replace_with / sensitive_data_route_to_model or guardrail-specific mask config) so text is transformed instead of rejected","Scope the guardrail: disable it for specific keys/teams, exclude entity types, or tighten the detection rules that produced the false positive"],"exampleFix":"# before\nmessages = [{\"role\": \"user\", \"content\": \"Email john.doe@corp.com about the invoice\"}]\n\n# after (pre-redact, or use a masking guardrail config)\nmessages = [{\"role\": \"user\", \"content\": \"Email <EMAIL> about the invoice\"}]","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.integrations.custom_guardrail import GuardrailRaisedException\n\ntry:\n    result = litellm.completion(model=\"gpt-4o\", messages=msgs)\nexcept GuardrailRaisedException as e:\n    # policy decision: inform user, log, or sanitize + retry\n    return sanitize_and_retry(msgs, e)","preventionTips":["Redact PII client-side before sending when block-mode guardrails are active","Prefer mask-mode over block-mode for user-facing apps to avoid hard failures","Log guardrail_name from the exception to identify which rule fired and tune it"],"tags":["guardrail","pii","blocking","compliance"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}