From ce2cf8a0907731bf9a3d03131371181b1ac3087e Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Thu, 5 Mar 2026 17:24:14 -0800 Subject: [PATCH] Move team iteration inside try/except and remove redundant model_dump() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .../internal_user_endpoints.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/litellm/proxy/management_endpoints/internal_user_endpoints.py b/litellm/proxy/management_endpoints/internal_user_endpoints.py index a209d1789ed..f6771ecbf5b 100644 --- a/litellm/proxy/management_endpoints/internal_user_endpoints.py +++ b/litellm/proxy/management_endpoints/internal_user_endpoints.py @@ -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