BerriAI/litellm · error · BlockedPiiEntityError

Blocked entity detected: {entity_type} by Guardrail: {guardr

Error message

Blocked entity detected: {entity_type} by Guardrail: {guardrail_name}. This entity is not allowed to be used in this request.

What it means

Error "Blocked entity detected: {entity_type} by Guardrail: {guardrail_name}. This entity is not allowed to be used in this request." thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/guardrails/guardrail_hooks/presidio.py:595

    ):
        """
        Raise an exception if blocked entities are detected
        """
        if self.pii_entities_config is None:
            return

        if isinstance(analyze_results, dict):
            # if mock testing is enabled, analyze_results is a dict
            # we don't need to raise an exception in this case
            return

        for result in analyze_results:
            entity_type = result.get("entity_type")

            if entity_type:
                # Check if entity_type is in config (supports both enum and string)
                if entity_type in self.pii_entities_config and self.pii_entities_config[entity_type] == PiiAction.BLOCK:
                    raise BlockedPiiEntityError(
                        entity_type=entity_type,
                        guardrail_name=self.guardrail_name,
                    )

    async def check_pii(
        self,
        text: str,
        output_parse_pii: bool,
        presidio_config: PresidioPerRequestConfig | None,
        request_data: dict,
    ) -> str:
        """
        Calls Presidio Analyze + Anonymize endpoints for PII Analysis + Masking
        """
        start_time: Final = datetime.now()
        analyze_results: list[PresidioAnalyzeResponseItem] | _PresidioAnonymizeResponse | None = None
        status: GuardrailStatus = "success"
        masked_entity_count: Final[dict[str, int]] = {}

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Remove the blocked PII entity from the request, or add the entity type to the allowed list for this guardrail.
  2. Adjust the Presidio blocked entities configuration if the entity should be permitted.

When it happens

Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/presidio.py:595 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/05743e0c07e65684. Report an issue: GitHub.