{"record":{"id":"db25c2d0a3c84197","repo":"BerriAI/litellm","slug":"azure-content-safety-guardrail-name-is-required","errorCode":null,"errorMessage":"Azure Content Safety: guardrail_name is required","messagePattern":"Azure Content Safety: guardrail_name is required","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_hooks/azure/__init__.py","lineNumber":24,"sourceCode":"from .text_moderation import AzureContentSafetyTextModerationGuardrail\n\nif TYPE_CHECKING:\n    from litellm.types.guardrails import Guardrail, LitellmParams\n\n\ndef initialize_guardrail(litellm_params: \"LitellmParams\", guardrail: \"Guardrail\"):\n    import litellm\n\n    if not litellm_params.api_key:\n        raise ValueError(\"Azure Content Safety: api_key is required\")\n    if not litellm_params.api_base:\n        raise ValueError(\"Azure Content Safety: api_base is required\")\n\n    azure_guardrail: Final = litellm_params.guardrail.split(\"/\")[1]\n\n    guardrail_name: Final = guardrail.get(\"guardrail_name\")\n    if not guardrail_name:\n        raise ValueError(\"Azure Content Safety: guardrail_name is required\")\n\n    if azure_guardrail == \"prompt_shield\":\n        azure_content_safety_guardrail: (\n            AzureContentSafetyPromptShieldGuardrail | AzureContentSafetyTextModerationGuardrail\n        ) = AzureContentSafetyPromptShieldGuardrail(\n            guardrail_name=guardrail_name,\n            **{\n                **litellm_params.model_dump(exclude_none=True),\n                \"api_key\": litellm_params.api_key,\n                \"api_base\": litellm_params.api_base,\n                \"default_on\": litellm_params.default_on,\n                \"event_hook\": litellm_params.mode,\n            },\n        )\n    elif azure_guardrail == \"text_moderations\":\n        azure_content_safety_guardrail = AzureContentSafetyTextModerationGuardrail(\n            guardrail_name=guardrail_name,\n            **{","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_hooks/azure/__init__.py#L6-L42","documentation":"Init guard for Azure Content Safety: the guardrail config entry lacks guardrail_name, which is needed to register and look up the callback instance.","triggerScenarios":"Thrown at litellm/proxy/guardrails/guardrail_hooks/azure/__init__.py:24 when the library encounters an invalid state.","commonSituations":"Azure Content Safety guardrail missing the guardrail_name field.","solutions":["Set guardrail_name in the Azure Content Safety guardrail config."],"exampleFix":"guardrail_name: azure_content_safety","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}