Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(guardrails): use plural key in get_disable_global_guardrail

Ryan Crabbeef38c665ca38
diff --git a/litellm/integrations/custom_guardrail.py b/litellm/integrations/custom_guardrail.py
index aa2a8121ee8..c95010e7f31 100644
--- a/litellm/integrations/custom_guardrail.py
+++ b/litellm/integrations/custom_guardrail.py
@@ -259,11 +259,11 @@ class CustomGuardrail(CustomLogger):
"""
Returns True if the global guardrail should be disabled
"""
- if "disable_global_guardrail" in data:
- return data["disable_global_guardrail"]
+ if "disable_global_guardrails" in data:
+ return data["disable_global_guardrails"]
metadata = data.get("litellm_metadata") or data.get("metadata", {})
- if "disable_global_guardrail" in metadata:
- return metadata["disable_global_guardrail"]
+ if "disable_global_guardrails" in metadata:
+ return metadata["disable_global_guardrails"]
return False
def _is_valid_response_type(self, result: Any) -> bool:
diff --git a/tests/test_litellm/integrations/test_custom_guardrail.py b/tests/test_litellm/integrations/test_custom_guardrail.py
index 7c60cbb52ee..abbb572826b 100644
--- a/tests/test_litellm/integrations/test_custom_guardrail.py
+++ b/tests/test_litellm/integrations/test_custom_guardrail.py
@@ -197,7 +197,7 @@ class TestCustomGuardrailShouldRunGuardrail:
data_with_disable_root = {
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "test"}],
- "disable_global_guardrail": True,
+ "disable_global_guardrails": True,
}
result = custom_guardrail.should_run_guardrail(
data=data_with_disable_root, event_type=GuardrailEventHooks.pre_call
@@ -210,7 +210,7 @@ class TestCustomGuardrailShouldRunGuardrail:
data_with_disable_litellm = {
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "test"}],
- "litellm_metadata": {"disable_global_guardrail": True},
+ "litellm_metadata": {"disable_global_guardrails": True},
}
result = custom_guardrail.should_run_guardrail(
data=data_with_disable_litellm, event_type=GuardrailEventHooks.pre_call
@@ -223,7 +223,7 @@ class TestCustomGuardrailShouldRunGuardrail:
data_with_disable_metadata = {
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "test"}],
- "metadata": {"disable_global_guardrail": True},
+ "metadata": {"disable_global_guardrails": True},
}
result = custom_guardrail.should_run_guardrail(
data=data_with_disable_metadata, event_type=GuardrailEventHooks.pre_call
@@ -236,7 +236,7 @@ class TestCustomGuardrailShouldRunGuardrail:
data_with_disable_false = {
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "test"}],
- "disable_global_guardrail": False,
+ "disable_global_guardrails": False,
}
result = custom_guardrail.should_run_guardrail(
data=data_with_disable_false, event_type=GuardrailEventHooks.pre_call
diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_panw_prisma_airs.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_panw_prisma_airs.py
index 7486f602dd9..ace3901b374 100644
--- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_panw_prisma_airs.py
+++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_panw_prisma_airs.py
@@ -2263,7 +2263,7 @@ class TestPanwAirsMcpForceRun:
"test_panw_airs",
False,
"pre_call",
- _simple_data(disable_global_guardrail=True),
+ _simple_data(disable_global_guardrails=True),
GuardrailEventHooks.pre_mcp_call,
False,
id="honors_disable_global_on_mcp_hooks",