BerriAI/litellm · error · LassoGuardrailAPIError

Failed to apply post-call masking: {e}

Error message

Failed to apply post-call masking: {e}

What it means

Error "Failed to apply post-call masking: {e}" thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/guardrails/guardrail_hooks/lasso/lasso.py:300

                if self.mask:
                    headers: Final = self._prepare_headers(response_data, global_cache)
                    payload: Final = self._prepare_payload(response_messages, response_data, global_cache, "COMPLETION")
                    api_url: Final = f"{self.api_base}/classifix"

                    try:
                        lasso_response = await self._call_lasso_api(headers=headers, payload=payload, api_url=api_url)
                        self._process_lasso_response(lasso_response)

                        # Apply masking to the actual response if masked content is available
                        masked_messages: Final = lasso_response.get("messages")
                        if lasso_response.get("violations_detected") and masked_messages:
                            self._apply_masking_to_model_response(response, masked_messages)
                            verbose_proxy_logger.debug("Applied Lasso masking to model response")
                    except Exception as e:
                        if isinstance(e, HTTPException):
                            raise e
                        verbose_proxy_logger.error("Error in post-call Lasso masking: %s", e)
                        raise LassoGuardrailAPIError(f"Failed to apply post-call masking: {e}")
                else:
                    # Use the same data for conversation_id consistency (no cache access needed)
                    await self._run_lasso_guardrail(response_data, cache=global_cache, message_type="COMPLETION")
                    verbose_proxy_logger.debug("Post-call Lasso validation completed")
            else:
                verbose_proxy_logger.warning("No response messages found to validate")
        else:
            verbose_proxy_logger.warning("Unexpected response type for post-call hook: %s", type(response))

        return response

    def _get_or_generate_conversation_id(self, data: dict, cache: DualCache) -> str:
        """
        Get or generate a conversation_id for this request.

        This method ensures session consistency by using litellm_call_id as a cache key.
        The same conversation_id is used for both pre-call and post-call hooks within
        the same request, enabling proper conversation grouping in Lasso UI.

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check the underlying exception message for the masking failure cause.
  2. Verify the Lasso de-identification/masking configuration (entities, masking rules) is valid.
  3. If masking is optional, disable post-call masking or set block_on_error appropriately.

When it happens

Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/lasso/lasso.py:300 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/f452ca15728bf404. Report an issue: GitHub.