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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(proxy): catch callback metadata validation errors
user1ebb192cbed0
diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.pyindex ceadf823798..635c0d41481 100644--- a/litellm/proxy/litellm_pre_call_utils.py+++ b/litellm/proxy/litellm_pre_call_utils.py@@ -6,6 +6,7 @@ from collections import OrderedDictfrom typing import TYPE_CHECKING, Any, Dict, List, Optional, Unionfrom fastapi import Request+from pydantic import ValidationError as PydanticValidationErrorfrom starlette.datastructures import Headersimport litellm@@ -238,7 +239,7 @@ def _get_validated_callback_metadata() -> Optional[AddTeamCallback]:try:return AddTeamCallback(**item)- except ValueError as e:+ except (PydanticValidationError, ValueError) as e:verbose_proxy_logger.warning("Ignoring invalid %s callback metadata: %s",source,diff --git a/tests/test_litellm/proxy/test_litellm_pre_call_utils.py b/tests/test_litellm/proxy/test_litellm_pre_call_utils.pyindex 543be7948f0..d4319593d60 100644--- a/tests/test_litellm/proxy/test_litellm_pre_call_utils.py+++ b/tests/test_litellm/proxy/test_litellm_pre_call_utils.py@@ -7,6 +7,7 @@ from unittest.mock import AsyncMock, MagicMock, patchimport pytestfrom fastapi import Request+from pydantic import ValidationError as PydanticValidationErrorfrom starlette.datastructures import Headersimport litellm@@ -1275,7 +1276,7 @@ def test_get_dynamic_logging_metadata_with_arize_team_logging():def test_add_team_callback_rejects_env_reference():- with pytest.raises(ValueError) as exc_info:+ with pytest.raises(PydanticValidationError) as exc_info:AddTeamCallback(callback_name="langfuse",callback_type="success",