From edf7eb867d5e6813f5280896db87db39bac59e2c Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Thu, 20 Mar 2025 20:28:03 -0700 Subject: [PATCH] fix(team_endpoints.py): consistently return 404 if team not found in DB Fixes response on /team/delete --- litellm/proxy/management_endpoints/team_endpoints.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.py index 1994e27ecf..f5bcc6ba11 100644 --- a/litellm/proxy/management_endpoints/team_endpoints.py +++ b/litellm/proxy/management_endpoints/team_endpoints.py @@ -470,7 +470,7 @@ async def update_team( if existing_team_row is None: raise HTTPException( - status_code=400, + status_code=404, detail={"error": f"Team not found, passed team_id={data.team_id}"}, ) @@ -1137,14 +1137,16 @@ async def delete_team( team_rows: List[LiteLLM_TeamTable] = [] for team_id in data.team_ids: try: - team_row_base: BaseModel = ( + team_row_base: Optional[BaseModel] = ( await prisma_client.db.litellm_teamtable.find_unique( where={"team_id": team_id} ) ) + if team_row_base is None: + raise Exception except Exception: raise HTTPException( - status_code=400, + status_code=404, detail={"error": f"Team not found, passed team_id={team_id}"}, ) team_row_pydantic = LiteLLM_TeamTable(**team_row_base.model_dump())