fix(team_endpoints.py): consistently return 404 if team not found in DB

Fixes response on /team/delete
This commit is contained in:
Krrish Dholakia 2025-03-20 20:28:03 -07:00
parent d415738860
commit edf7eb867d

View file

@ -470,7 +470,7 @@ async def update_team(
if existing_team_row is None: if existing_team_row is None:
raise HTTPException( raise HTTPException(
status_code=400, status_code=404,
detail={"error": f"Team not found, passed team_id={data.team_id}"}, 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] = [] team_rows: List[LiteLLM_TeamTable] = []
for team_id in data.team_ids: for team_id in data.team_ids:
try: try:
team_row_base: BaseModel = ( team_row_base: Optional[BaseModel] = (
await prisma_client.db.litellm_teamtable.find_unique( await prisma_client.db.litellm_teamtable.find_unique(
where={"team_id": team_id} where={"team_id": team_id}
) )
) )
if team_row_base is None:
raise Exception
except Exception: except Exception:
raise HTTPException( raise HTTPException(
status_code=400, status_code=404,
detail={"error": f"Team not found, passed team_id={team_id}"}, detail={"error": f"Team not found, passed team_id={team_id}"},
) )
team_row_pydantic = LiteLLM_TeamTable(**team_row_base.model_dump()) team_row_pydantic = LiteLLM_TeamTable(**team_row_base.model_dump())