From 367d86047c2e43783a99bd181604435e26532956 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 20 May 2024 17:36:08 -0700 Subject: [PATCH] fix - raise Exception when trying to update/delete a non-existtent team --- litellm/proxy/proxy_server.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 351984c2b..0977bb8d5 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -7444,6 +7444,11 @@ async def update_team( existing_team_row = await prisma_client.get_data( team_id=data.team_id, table_name="team", query_type="find_unique" ) + if existing_team_row is None: + raise HTTPException( + status_code=404, + detail={"error": f"Team not found, passed team_id={data.team_id}"}, + ) updated_kv = data.json(exclude_none=True) team_row = await prisma_client.update_data( @@ -7697,6 +7702,17 @@ async def delete_team( if data.team_ids is None: raise HTTPException(status_code=400, detail={"error": "No team id passed in"}) + # check that all teams passed exist + for team_id in data.team_ids: + team_row = await prisma_client.get_data( # type: ignore + team_id=team_id, table_name="team", query_type="find_unique" + ) + if team_row is None: + raise HTTPException( + status_code=404, + detail={"error": f"Team not found, passed team_id={team_id}"}, + ) + ## DELETE ASSOCIATED KEYS await prisma_client.delete_data(team_id_list=data.team_ids, table_name="key") ## DELETE TEAMS