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): define UserNotFoundError in an import-free types module so no importer sits in the CodeQL cycle
yassin4fee71b7ad99
diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.pyindex 412b902febc..49e0247aad9 100644--- a/litellm/proxy/_types.py+++ b/litellm/proxy/_types.py@@ -3954,13 +3954,6 @@ class ManagementEndpointLoggingPayload(LiteLLMPydanticObjectBase):end_time: datetime | None = None-class UserNotFoundError(ValueError):- """The user row is provably absent, as opposed to merely unreadable, so a caller that reads a missing row as no user-level limits can key on it without also swallowing a database that would not answer."""-- def __init__(self, user_id: str) -> None:- super().__init__(f"User doesn't exist in db. 'user_id'={user_id}. Create user via `/user/new` call.")--class ProxyException(Exception):# NOTE: DO NOT MODIFY THIS# This is used to map exactly to OPENAI Exceptionsdiff --git a/litellm/proxy/auth/auth_checks.py b/litellm/proxy/auth/auth_checks.pyindex 6f4e5cd3ca1..0cbb4a38aba 100644--- a/litellm/proxy/auth/auth_checks.py+++ b/litellm/proxy/auth/auth_checks.py@@ -65,7 +65,6 @@ from litellm.proxy._types import (RoleBasedPermissions,SpecialModelNames,UserAPIKeyAuth,- UserNotFoundError,)from litellm.proxy.auth.budget_throttle import (budget_throttle_percentage,@@ -124,6 +123,7 @@ from litellm.repositories.table_repositories import (from litellm.repositories.team_repository import TeamRepositoryfrom litellm.repositories.user_repository import UserRepositoryfrom litellm.router import Router+from litellm.types.proxy.auth.auth_checks import UserNotFoundErrorfrom litellm.types.proxy.model_access_group_budget import ModelAccessGroupBudgetfrom litellm.utils import get_utc_datetimediff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.pyindex a627c1438dc..6b16692f7ad 100644--- a/litellm/proxy/management_endpoints/team_endpoints.py+++ b/litellm/proxy/management_endpoints/team_endpoints.py@@ -73,7 +73,6 @@ from litellm.proxy._types import (TeamModelDeleteRequest,UpdateTeamRequest,UserAPIKeyAuth,- UserNotFoundError,)from litellm.proxy.auth.auth_checks import (OrganizationNotFoundError,@@ -157,6 +156,7 @@ from litellm.repositories.verification_token_repository import (VerificationTokenRepository,)from litellm.router import Router+from litellm.types.proxy.auth.auth_checks import UserNotFoundErrorfrom litellm.types.proxy.management_endpoints.common_daily_activity import (SpendAnalyticsPaginatedResponse,)diff --git a/litellm/types/proxy/auth/auth_checks.py b/litellm/types/proxy/auth/auth_checks.pynew file mode 100644index 00000000000..80c65d14113--- /dev/null+++ b/litellm/types/proxy/auth/auth_checks.py@@ -0,0 +1,8 @@+"""Failure values raised by `litellm/proxy/auth/auth_checks.py`. Kept free of `litellm` imports so any proxy module can import them without joining the `litellm.proxy` import cycle."""+++class UserNotFoundError(ValueError):+ """The user row is provably absent, as opposed to merely unreadable, so a caller that reads a missing row as no user-level limits can key on it without also swallowing a database that would not answer."""++ def __init__(self, user_id: str) -> None:+ super().__init__(f"User doesn't exist in db. 'user_id'={user_id}. Create user via `/user/new` call.")