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: add break on match and guard empty normalized_route in mapped route checks
joereyna791e598ad546
diff --git a/litellm/proxy/auth/user_api_key_auth.py b/litellm/proxy/auth/user_api_key_auth.pyindex 40a1e250689..e57adfda05d 100644--- a/litellm/proxy/auth/user_api_key_auth.py+++ b/litellm/proxy/auth/user_api_key_auth.py@@ -390,13 +390,16 @@ async def check_api_key_for_custom_headers_or_pass_through_endpoints(if root_path and root_path != "/":if route.startswith(root_path):normalized_route = route[len(root_path):]- for mapped_route in LiteLLMRoutes.mapped_pass_through_routes.value: # type: ignore- if normalized_route.startswith(mapped_route):- is_mapped_pass_through_route = True+ if normalized_route: # guard against route == root_path exactly+ for mapped_route in LiteLLMRoutes.mapped_pass_through_routes.value: # type: ignore+ if normalized_route.startswith(mapped_route):+ is_mapped_pass_through_route = True+ breakelse:for mapped_route in LiteLLMRoutes.mapped_pass_through_routes.value: # type: ignoreif route.startswith(mapped_route):is_mapped_pass_through_route = True+ breakif is_mapped_pass_through_route:if request.headers.get("litellm_user_api_key") is not None:api_key = request.headers.get("litellm_user_api_key") or ""diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.pyindex 8d6a4c00b71..3c208fc8d30 100644--- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py+++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py@@ -2065,10 +2065,11 @@ class InitPassThroughEndpointHelpers:if root_path and root_path != "/":if route.startswith(root_path):normalized_route = route[len(root_path):]- for mapped_route in LiteLLMRoutes.mapped_pass_through_routes.value:- if normalized_route.startswith(mapped_route):- return True- # Route lacks expected prefix — not a mapped pass-through route+ if normalized_route: # guard against route == root_path exactly+ for mapped_route in LiteLLMRoutes.mapped_pass_through_routes.value:+ if normalized_route.startswith(mapped_route):+ return True+ # Route lacks expected prefix (or is exactly root_path) — not a mapped pass-through routeelse:for mapped_route in LiteLLMRoutes.mapped_pass_through_routes.value:if route.startswith(mapped_route):