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: use real State object in mock_request to fix _safe_get_request_headers
Julio Quinteros Pro740cdc5c20b2
diff --git a/tests/proxy_unit_tests/test_proxy_utils.py b/tests/proxy_unit_tests/test_proxy_utils.pyindex f7101085f0f..b2ed4f91037 100644--- a/tests/proxy_unit_tests/test_proxy_utils.py+++ b/tests/proxy_unit_tests/test_proxy_utils.py@@ -8,6 +8,7 @@ from unittest.mock import Mockimport pytestfrom fastapi import Request+from starlette.datastructures import Statefrom litellm.proxy.utils import _get_docs_url, _get_redoc_url@@ -32,6 +33,7 @@ def mock_request(monkeypatch):mock_request = Mock(spec=Request)mock_request.query_params = {} # Set mock query_params to an empty dictionarymock_request.headers = {"traceparent": "test_traceparent"}+ mock_request.state = State() # Real State so _safe_get_request_headers caching worksmonkeypatch.setattr("litellm.proxy.litellm_pre_call_utils.add_litellm_data_to_request", mock_request)@@ -810,6 +812,7 @@ async def test_add_litellm_data_to_request_duplicate_tags(mock_request.url.path = "/chat/completions"mock_request.query_params = {}mock_request.headers = {}+ mock_request.state = State()# Setup key with tags in metadatauser_api_key_dict = UserAPIKeyAuth(