diff --git a/litellm/constants.py b/litellm/constants.py index 3b91f23fe39..42b7513a220 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -1334,6 +1334,8 @@ LITELLM_TRUNCATION_DB_SAFEGUARD_NOTE: Final = ( ########################### LiteLLM Proxy Specific Constants ########################### ######################################################################################## +UNMATCHED_REQUEST_ROUTE: Final = "/unmatched" + # Standard headers that are always checked for customer/end-user ID (no configuration required) # These headers work out-of-the-box for tools like Claude Code that support custom headers STANDARD_CUSTOMER_ID_HEADERS: Final = [ diff --git a/litellm/proxy/auth/auth_utils.py b/litellm/proxy/auth/auth_utils.py index ae294fee376..ed2ddfea899 100644 --- a/litellm/proxy/auth/auth_utils.py +++ b/litellm/proxy/auth/auth_utils.py @@ -11,7 +11,7 @@ from fastapi import HTTPException, Request, status import litellm from litellm import Router, provider_list from litellm._logging import verbose_proxy_logger -from litellm.constants import MINIMUM_CUSTOM_KEY_LENGTH, STANDARD_CUSTOMER_ID_HEADERS +from litellm.constants import MINIMUM_CUSTOM_KEY_LENGTH, STANDARD_CUSTOMER_ID_HEADERS, UNMATCHED_REQUEST_ROUTE from litellm.litellm_core_utils.safe_json_loads import safe_json_loads from litellm.litellm_core_utils.url_utils import ( SSRFError, @@ -767,8 +767,6 @@ def normalize_request_route(route: str) -> str: return route -UNMATCHED_REQUEST_ROUTE: Final = "/unmatched" - # Literal proxy routes safe to emit when FastAPI's route template is unavailable # (e.g. auth failure on an unmatched scope). Dynamic segments must never appear # here — those are covered by get_request_route_template() or normalize_request_route(). diff --git a/tests/test_litellm/integrations/test_prometheus_labels.py b/tests/test_litellm/integrations/test_prometheus_labels.py index 568b3b57e40..000b05220a9 100644 --- a/tests/test_litellm/integrations/test_prometheus_labels.py +++ b/tests/test_litellm/integrations/test_prometheus_labels.py @@ -451,10 +451,8 @@ def test_route_normalization_preserves_static_routes(): def test_unmatched_scanner_routes_collapse_for_metrics(): """Unknown paths must not create unbounded Prometheus route labels.""" - from litellm.proxy.auth.auth_utils import ( - UNMATCHED_REQUEST_ROUTE, - resolve_request_route_for_metrics, - ) + from litellm.constants import UNMATCHED_REQUEST_ROUTE + from litellm.proxy.auth.auth_utils import resolve_request_route_for_metrics scanner_paths = [ "/files/pRzAdaV1.php", diff --git a/tests/test_litellm/proxy/auth/test_auth_utils.py b/tests/test_litellm/proxy/auth/test_auth_utils.py index d8c3e0176e2..ee2cd43584d 100644 --- a/tests/test_litellm/proxy/auth/test_auth_utils.py +++ b/tests/test_litellm/proxy/auth/test_auth_utils.py @@ -2951,10 +2951,8 @@ class TestResolveRequestRouteForMetrics: assert resolve_request_route_for_metrics(None, route) == route def test_collapses_unknown_paths_to_unmatched(self): - from litellm.proxy.auth.auth_utils import ( - UNMATCHED_REQUEST_ROUTE, - resolve_request_route_for_metrics, - ) + from litellm.constants import UNMATCHED_REQUEST_ROUTE + from litellm.proxy.auth.auth_utils import resolve_request_route_for_metrics scanner_paths = [ "/files/pRzAdaV1.php",