{"record":{"id":"f1f9b6a80811c9e0","repo":"mlflow/mlflow","slug":"e-f1f9b6","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"http","errorClass":"HTTPException (GuardrailViolation message)","httpStatus":400,"severity":"warning","filePath":"mlflow/server/gateway_api.py","lineNumber":771,"sourceCode":"                    request_dict,\n                    response,\n                    auth_headers=auth_headers,\n                    usage_tracking=endpoint_config.usage_tracking,\n                )\n\n            try:\n                return await maybe_traced_gateway_call(\n                    _guarded_chat,\n                    endpoint_config,\n                    user_metadata,\n                    request_headers=headers,\n                    request_type=GatewayRequestType.UNIFIED_CHAT,\n                    on_complete=make_budget_on_complete(\n                        store, workspace, endpoint_config.endpoint_id\n                    ),\n                )(payload)\n            except GuardrailViolation as e:\n                raise HTTPException(status_code=400, detail=str(e))\n\n    elif \"input\" in body:\n        # Embeddings request\n        endpoint_type = EndpointType.LLM_V1_EMBEDDINGS\n        try:\n            payload = embeddings.RequestPayload(**body)\n        except Exception as e:\n            raise HTTPException(status_code=400, detail=f\"Invalid embeddings payload: {e!s}\")\n\n        provider, endpoint_config = _create_provider_from_endpoint_name(\n            store, endpoint_name, endpoint_type\n        )\n\n        return await maybe_traced_gateway_call(\n            provider.embeddings,\n            endpoint_config,\n            user_metadata,\n            request_headers=headers,","sourceCodeStart":753,"sourceCodeEnd":789,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/server/gateway_api.py#L753-L789","documentation":"In the /invocations route, after a chat request completes, a pre-LLM guardrail can raise GuardrailViolation. The handler converts it to HTTP 400 with the guardrail's own message as detail, so the payload text is just the guardrail violation reason (e.g. PII detected, banned content).","triggerScenarios":"Invoking a chat endpoint whose config defines guardrails (e.g. pii/redaction or content filters) and the submitted message content trips a pre-LLM guardrail check.","commonSituations":"Users pasting credit card numbers/emails into a chat app with PII guardrails; prompts containing blocked keywords configured by the admin.","solutions":["Read the detail text to see which guardrail fired and remove the offending content from the prompt.","Redact or sanitize inputs client-side (e.g. strip emails/PII) before sending.","If the guardrail is too strict, adjust the guardrail configuration on the endpoint (rules/regexes) or remove it."],"exampleFix":"// before\n{\"messages\":[{\"role\":\"user\",\"content\":\"email me at foo@bar.com\"}]}\n\n// after\n{\"messages\":[{\"role\":\"user\",\"content\":\"email me at [REDACTED]\"}]}","handlingStrategy":"try-catch","validationCode":"# pre-check input against your own guardrail rules client-side\nimport re\nif re.search(PII_PATTERN, user_text):\n    user_text = redact(user_text)","typeGuard":null,"tryCatchPattern":"try:\n    resp = requests.post(url, json=body)\nexcept requests.HTTPError as e:\n    if e.response.status_code == 400:\n        raise UserInputError(e.response.text) from e  # show guardrail reason to end user","preventionTips":["Redact PII/blocked content in the client before calling the gateway.","Document endpoint guardrail rules for API consumers.","Log guardrail rejections to tune overly strict rules."],"tags":["guardrails","http-400","content-filter","gateway"],"backgroundTag":"guardrail-violation","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}