{"record":{"id":"50ca4cdd6eacf2e0","repo":"BerriAI/litellm","slug":"violated-lasso-guardrail-policy","errorCode":null,"errorMessage":"Violated Lasso guardrail policy","messagePattern":"Violated Lasso guardrail policy","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_hooks/lasso/lasso.py","lineNumber":856,"sourceCode":"                }\n            }\n\n        Args:\n            response: The response dictionary from Lasso API\n\n        Raises:\n            HTTPException: If any finding has \"action\": \"BLOCK\"\n        \"\"\"\n        if response and response.get(\"violations_detected\") is True:\n            violated_deputies: Final = self._parse_violated_deputies(response)\n            verbose_proxy_logger.warning(\"Lasso guardrail detected violations: %s\", violated_deputies)\n\n            # Check if any findings have \"BLOCK\" action\n            blocking_violations: Final = self._check_for_blocking_actions(response)\n\n            if blocking_violations:\n                # Block the request/response for findings with \"BLOCK\" action\n                raise HTTPException(\n                    status_code=400,\n                    detail={\n                        \"error\": \"Violated Lasso guardrail policy\",\n                        \"detection_message\": f\"Blocking violations detected: {', '.join(blocking_violations)}\",\n                        \"lasso_response\": response,\n                    },\n                )\n            else:\n                # Continue with warning for non-blocking violations (e.g., AUTO_MASKING)\n                verbose_proxy_logger.info(\n                    \"Non-blocking Lasso violations detected, continuing with warning: %s\", violated_deputies\n                )\n\n    def _check_for_blocking_actions(self, response: LassoResponse) -> list[str]:\n        \"\"\"\n        Check findings for actions that should block the request/response.\n\n        Examines the findings section of the Lasso response to identify which","sourceCodeStart":838,"sourceCodeEnd":874,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_hooks/lasso/lasso.py#L838-L874","documentation":"An HTTPException(400) raised by the Lasso guardrail when the Lasso response has violations_detected=true and at least one finding carries action BLOCK. This is the guardrail enforcing policy, not a malfunction: the request or response is rejected, and the detail payload includes a detection_message naming the blocking findings plus the raw lasso_response.","triggerScenarios":"A pre_call or post_call hook sends content to Lasso; the response sets violations_detected=true; _parse_violated_deputies extracts findings and _check_for_blocking_actions finds at least one 'action': 'BLOCK', so litellm raises HTTPException 400 to the caller.","commonSituations":"End users sending content that Lasso deputies (PII, prompt-injection, toxicity policies) are configured to block; a newly tightened Lasso policy suddenly blocking previously-allowed traffic; testing pipelines that replay real user prompts against a blocking policy.","solutions":["Inspect the HTTP 400 detail: detection_message lists the blocking findings and lasso_response holds the full Lasso payload — fix the specific policy/deputy it names.","If the content class should be softened, change the offending deputy's action in the Lasso policy from BLOCK to AUTO_MASKING/MASK so the guardrail logs and continues instead of blocking.","If the block is correct, handle it client-side: surface a friendly policy-violation message to the user instead of retrying (a retry will block again).","Sanitize the offending input (redact PII, remove flagged phrases) before resubmitting."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"# Server/client side: recognize a deliberate Lasso block and stop retrying\nfrom fastapi import HTTPException\n\ntry:\n    resp = await client.chat.completions.create(**params)\nexcept HTTPException as e:\n    detail = e.detail if isinstance(e.detail, dict) else {\"error\": str(e.detail)}\n    if e.status_code == 400 and detail.get(\"error\") == \"Violated Lasso guardrail policy\":\n        findings = detail.get(\"detection_message\", \"\")\n        raise PolicyRejectedError(\n            user_message=\"Your request was blocked by the content policy.\",\n            findings=findings,  # for internal audit only — never expose lasso_response to users\n        ) from e\n    raise","preventionTips":["Tune Lasso deputies so soft violations use MASK/AUTO_MASKING and only high-confidence classes BLOCK.","Replay representative traffic through a staging Lasso policy before tightening BLOCK rules in production.","Never forward the raw lasso_response detail to end users — log it internally for audits.","Map this 400 to a first-class 'policy rejected' error in your API contract so clients do not auto-retry."],"tags":["content-moderation","policy-violation","lasso","guardrails","http-400"],"backgroundTag":"content-policy-violation","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}