Move team iteration inside try/except and remove redundant model_dump()

- Move the for-loop over team_rows inside the try/except block so that
  a Pydantic ValidationError during LiteLLM_TeamTable construction is
  caught and logged instead of propagating as a 500.
- Pass user_info directly to UserInfoV2Response instead of calling
  model_dump() first, avoiding unnecessary dict→Pydantic re-validation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
yuneng-jiang 2026-03-05 17:24:14 -08:00
parent 771c13d56b
commit ce2cf8a090

View file

@ -800,7 +800,7 @@ async def user_info_v2(
)
return UserInfoV2Response(
user_info=user_info.model_dump(),
user_info=user_info,
)
except Exception as e:
verbose_proxy_logger.exception(
@ -828,18 +828,16 @@ async def _is_team_admin_for_user(
team_rows = await prisma_client.db.litellm_teamtable.find_many(
where={"team_id": {"in": target_user_teams}}
)
for row in team_rows:
team_obj = LiteLLM_TeamTable(**row.model_dump())
if _is_user_team_admin(
user_api_key_dict=user_api_key_dict, team_obj=team_obj
):
return True
except Exception:
verbose_proxy_logger.exception(
"_is_team_admin_for_user: failed to fetch teams for user"
)
return False
for row in team_rows:
team_obj = LiteLLM_TeamTable(**row.model_dump())
if _is_user_team_admin(
user_api_key_dict=user_api_key_dict, team_obj=team_obj
):
return True
return False