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(proxy): accept non-string callback vars in default_team_settings (#40458)

devin-ai-integration[bot]6e9688562952
diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.py
index 2925226f235..da033dc2276 100644
--- a/litellm/proxy/litellm_pre_call_utils.py
+++ b/litellm/proxy/litellm_pre_call_utils.py
@@ -1760,7 +1760,9 @@ class LiteLLMProxyRequestSetup:
callback_vars_dict.pop("success_callback", None)
callback_vars_dict.pop("failure_callback", None)
callback_vars_dict = {
- key: (litellm.utils.get_secret(value, default_value=value) or value if isinstance(value, str) else value)
+ key: (
+ litellm.utils.get_secret(value, default_value=value) or value if isinstance(value, str) else str(value)
+ )
for key, value in callback_vars_dict.items()
}
diff --git a/tests/test_litellm/proxy/test_litellm_pre_call_utils.py b/tests/test_litellm/proxy/test_litellm_pre_call_utils.py
index 7564fa91c43..94aaa32519e 100644
--- a/tests/test_litellm/proxy/test_litellm_pre_call_utils.py
+++ b/tests/test_litellm/proxy/test_litellm_pre_call_utils.py
@@ -35,6 +35,7 @@ from litellm.proxy.litellm_pre_call_utils import (
)
from litellm.litellm_core_utils.core_helpers import get_litellm_metadata_from_kwargs
from litellm.litellm_core_utils.internal_call_metadata import MODEL_ACCESS_GROUP_METADATA_KEY
+from litellm.litellm_core_utils.redact_messages import _get_turn_off_message_logging_from_dynamic_params
from litellm.litellm_core_utils.get_provider_specific_headers import (
ProviderSpecificHeaderUtils,
)
@@ -7909,3 +7910,36 @@ async def test_client_supplied_omit_marker_never_reaches_the_spend_log(
if general_settings.get("missing_session_id") == "generate"
else "per-call-random-trace-id"
)
+
+
+def test_default_team_settings_bool_turn_off_message_logging_redacts():
+ from litellm.proxy.proxy_server import ProxyConfig
+
+ pc = ProxyConfig()
+ pc.config = {
+ "litellm_settings": {
+ "default_team_settings": [
+ {
+ "team_id": "team-redact",
+ "success_callback": ["gcs_bucket"],
+ "failure_callback": ["gcs_bucket"],
+ "turn_off_message_logging": True,
+ }
+ ]
+ }
+ }
+
+ callback_metadata = LiteLLMProxyRequestSetup.add_team_based_callbacks_from_config(
+ team_id="team-redact",
+ proxy_config=pc,
+ )
+
+ assert callback_metadata is not None
+ assert callback_metadata.success_callback == ["gcs_bucket"]
+ assert callback_metadata.callback_vars == {"turn_off_message_logging": "True"}
+ assert (
+ _get_turn_off_message_logging_from_dynamic_params(
+ {"standard_callback_dynamic_params": dict(callback_metadata.callback_vars)}
+ )
+ is True
+ )