From 9ba7d26597e75f35ff9aa9747296188ab34b654a Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 22 May 2024 20:26:56 -0700 Subject: [PATCH] feat - raise exception when creating team_id for exiting team_id --- litellm/proxy/proxy_server.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 25d6e79f8..9a96dba79 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -7454,7 +7454,7 @@ async def new_team( Example Request: ``` - curl --location 'http://0.0.0.0:8000/team/new' \ + curl --location 'http://0.0.0.0:4000/team/new' \ --header 'Authorization: Bearer sk-1234' \ @@ -7475,6 +7475,18 @@ async def new_team( if data.team_id is None: data.team_id = str(uuid.uuid4()) + else: + # Check if team_id exists already + _existing_team_id = await prisma_client.get_data( + team_id=data.team_id, table_name="team", query_type="find_unique" + ) + if _existing_team_id is not None: + raise HTTPException( + status_code=400, + detail={ + "error": f"Team id = {data.team_id} already exists. Please use a different team id." + }, + ) if ( user_api_key_dict.user_role is None