forked from phoenix/litellm-mirror
Merge pull request #3791 from BerriAI/litellm_fix_dont_allow_creating_existing_team_ids
[Fix] raise exception when creating team_id for existing team_id on `/team/new`
This commit is contained in:
commit
405d5aa726
1 changed files with 13 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue