From 9a62a5ebee7743c93d179039aa8311b87a4cb33a Mon Sep 17 00:00:00 2001 From: yassin Date: Mon, 14 Sep 2026 20:29:35 +0000 Subject: [PATCH] refactor(prometheus): source PROXY_LLM_PROVIDER_FALLBACK from litellm.constants Importing the fallback from litellm.proxy.hooks.rate_limiter_utils at the top of litellm/integrations/prometheus.py closed an import cycle CodeQL flagged on #41059 (rate_limiter_utils -> litellm -> ... -> prometheus). Hoist the constant into litellm/constants.py so both modules read it from a leaf module. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/constants.py | 3 +++ litellm/integrations/prometheus.py | 2 +- litellm/proxy/hooks/rate_limiter_utils.py | 3 +-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/litellm/constants.py b/litellm/constants.py index 5751e6e46af..aaa1e1484a2 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -227,6 +227,9 @@ PRE_CALL_EXECUTED_GUARDRAILS_KEY: Final = "_pre_call_executed_guardrails" # Attribute stamped on log_guardrail_information wrappers so __init_subclass__ does not wrap them again LOGS_GUARDRAIL_INFORMATION_MARKER: Final = "_litellm_logs_guardrail_information" +# llm_provider stamped on proxy-side rate limit errors when the model resolves to no deployment +PROXY_LLM_PROVIDER_FALLBACK: Final = "litellm_proxy" + # Generic fallback for unknown models DEFAULT_REASONING_EFFORT_MINIMAL_THINKING_BUDGET: Final = int( os.getenv("DEFAULT_REASONING_EFFORT_MINIMAL_THINKING_BUDGET", 128) diff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.py index 2ba5d471e75..69a38e83835 100644 --- a/litellm/integrations/prometheus.py +++ b/litellm/integrations/prometheus.py @@ -16,6 +16,7 @@ from pydantic import BaseModel import litellm from litellm._logging import print_verbose, verbose_logger +from litellm.constants import PROXY_LLM_PROVIDER_FALLBACK from litellm.exceptions import ( validate_rate_limit_category, validate_rate_limit_type, @@ -41,7 +42,6 @@ from litellm.proxy._types import ( LiteLLM_UserTable, UserAPIKeyAuth, ) -from litellm.proxy.hooks.rate_limiter_utils import PROXY_LLM_PROVIDER_FALLBACK from litellm.repositories.base_repository import BaseRepository from litellm.repositories.organization_repository import OrganizationRepository from litellm.repositories.team_repository import TeamRepository diff --git a/litellm/proxy/hooks/rate_limiter_utils.py b/litellm/proxy/hooks/rate_limiter_utils.py index cdc3896c10d..bbe38068638 100644 --- a/litellm/proxy/hooks/rate_limiter_utils.py +++ b/litellm/proxy/hooks/rate_limiter_utils.py @@ -6,11 +6,10 @@ from typing import Final import litellm from litellm._logging import verbose_proxy_logger +from litellm.constants import PROXY_LLM_PROVIDER_FALLBACK from litellm.types.router import ModelGroupInfo from litellm.types.utils import PriorityReservationDict -PROXY_LLM_PROVIDER_FALLBACK: Final = "litellm_proxy" - def resolve_llm_provider_for_rate_limit( model: str | None,