From dc088d9813a4e2742a0a35dd072023dd452871ac Mon Sep 17 00:00:00 2001 From: Srivatsa03 <180591884+Srivatsa03@users.noreply.github.com> Date: Mon, 12 Oct 2026 09:10:03 -0500 Subject: [PATCH] refactor(proxy): build LiteLLM_TeamTable via model_validate at **dict sites Adding max_tokens_budget and tokens_used to LiteLLM_TeamTable made the existing LiteLLM_TeamTable(**dict) constructions each flag two more basedpyright unknown-argument / argument-type errors, which the type-check ratchet forbids. model_validate takes the untyped dict as a single validated argument, so no per-field diagnostics fire. It is also the correct pydantic v2 way to build a model from a dict, and it leaves these call sites below their merge-base count. --- .../management_endpoints/scim/scim_transformations.py | 2 +- .../proxy/management_endpoints/team_callback_endpoints.py | 8 ++++---- litellm/proxy/management_endpoints/team_endpoints.py | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/litellm/proxy/management_endpoints/scim/scim_transformations.py b/litellm/proxy/management_endpoints/scim/scim_transformations.py index 6a67093fde8..26d48d96845 100644 --- a/litellm/proxy/management_endpoints/scim/scim_transformations.py +++ b/litellm/proxy/management_endpoints/scim/scim_transformations.py @@ -165,7 +165,7 @@ class ScimTransformations: raise HTTPException(status_code=500, detail={"error": "No database connected"}) if isinstance(team, dict): - team = LiteLLM_TeamTable(**team) + team = LiteLLM_TeamTable.model_validate(team) # Get team members with proper display names scim_members: Final[list[SCIMMember]] = [] diff --git a/litellm/proxy/management_endpoints/team_callback_endpoints.py b/litellm/proxy/management_endpoints/team_callback_endpoints.py index 3908ab3c927..9d05c431c45 100644 --- a/litellm/proxy/management_endpoints/team_callback_endpoints.py +++ b/litellm/proxy/management_endpoints/team_callback_endpoints.py @@ -341,7 +341,7 @@ async def add_team_callbacks( # authenticated key holder could overwrite another team's logging # config (and read back the credentials they wrote). if not await get_team_access().allows( - user_api_key_dict, LiteLLM_TeamTable(**_existing_team.model_dump()), TEAM_OR_ORG_ADMIN + user_api_key_dict, LiteLLM_TeamTable.model_validate(_existing_team.model_dump()), TEAM_OR_ORG_ADMIN ): team_access_denied() @@ -516,7 +516,7 @@ async def delete_team_callback( # deregister its callbacks, otherwise any authenticated key holder could # silence another team's observability integration. if not await get_team_access().allows( - user_api_key_dict, LiteLLM_TeamTable(**_existing_team.model_dump()), TEAM_OR_ORG_ADMIN + user_api_key_dict, LiteLLM_TeamTable.model_validate(_existing_team.model_dump()), TEAM_OR_ORG_ADMIN ): team_access_denied() @@ -649,7 +649,7 @@ async def disable_team_logging( # team may disable its logging — otherwise any authenticated key # holder can silence audit logging for any team. if not await get_team_access().allows( - user_api_key_dict, LiteLLM_TeamTable(**_existing_team.model_dump()), TEAM_OR_ORG_ADMIN + user_api_key_dict, LiteLLM_TeamTable.model_validate(_existing_team.model_dump()), TEAM_OR_ORG_ADMIN ): team_access_denied() @@ -790,7 +790,7 @@ async def get_team_callbacks( # (Langfuse / Langsmith / GCS). Only proxy admins / org admins / # team admins of THIS team may read them. if not await get_team_access().allows( - user_api_key_dict, LiteLLM_TeamTable(**_existing_team.model_dump()), TEAM_OR_ORG_ADMIN + user_api_key_dict, LiteLLM_TeamTable.model_validate(_existing_team.model_dump()), TEAM_OR_ORG_ADMIN ): team_access_denied() diff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.py index ae6da2ea98e..db3c31bd39d 100644 --- a/litellm/proxy/management_endpoints/team_endpoints.py +++ b/litellm/proxy/management_endpoints/team_endpoints.py @@ -1769,9 +1769,8 @@ async def new_team( ) ## ADD TO TEAM TABLE - complete_team_data: Final = LiteLLM_TeamTable( - **data_json, - model_id=_model_id, + complete_team_data: Final = LiteLLM_TeamTable.model_validate( + {**data_json, "model_id": _model_id}, ) # Set Management Endpoint Metadata Fields