fix(router): address Greptile review comments

- Add None guard for original_model_name in _add_team_model_to_db
- Remove stale old public name when renaming team model
- Add comment clarifying team deployment early-return priority

Made-with: Cursor
This commit is contained in:
Sameer Kankute 2026-03-23 16:25:26 +05:30
parent ce1651ef07
commit feabe36db1
2 changed files with 22 additions and 9 deletions

View file

@ -32,6 +32,7 @@ from litellm.proxy._types import (
ProxyErrorTypes,
ProxyException,
TeamModelAddRequest,
TeamModelDeleteRequest,
UpdateTeamRequest,
UserAPIKeyAuth,
)
@ -40,6 +41,7 @@ from litellm.proxy.common_utils.encrypt_decrypt_utils import encrypt_value_helpe
from litellm.proxy.management_endpoints.common_utils import _is_user_team_admin
from litellm.proxy.management_endpoints.team_endpoints import (
team_model_add,
team_model_delete,
update_team,
)
from litellm.proxy.management_helpers.audit_logs import create_object_audit_log
@ -344,14 +346,15 @@ async def _add_team_model_to_db(
prisma_client=prisma_client,
)
await team_model_add(
data=TeamModelAddRequest(
team_id=_team_id,
models=[original_model_name],
),
http_request=Request(scope={"type": "http"}),
user_api_key_dict=user_api_key_dict,
)
if original_model_name:
await team_model_add(
data=TeamModelAddRequest(
team_id=_team_id,
models=[original_model_name],
),
http_request=Request(scope={"type": "http"}),
user_api_key_dict=user_api_key_dict,
)
return model_response
@ -469,6 +472,14 @@ async def _update_existing_team_model_assignment(
)
if old_public_name and public_model_name != old_public_name:
await team_model_delete(
data=TeamModelDeleteRequest(
team_id=team_id,
models=[old_public_name],
),
http_request=Request(scope={"type": "http"}),
user_api_key_dict=user_api_key_dict,
)
await team_model_add(
data=TeamModelAddRequest(
team_id=team_id,

View file

@ -8781,7 +8781,9 @@ class Router:
model = _model_from_alias
if model not in self.model_names:
# Check for team-specific deployments by team_public_model_name
# Check for team-specific deployments by team_public_model_name.
# This intentionally takes priority over team pattern routers below,
# so that named team deployments shadow wildcard/pattern routes.
if request_team_id is not None:
team_deployments = self._get_all_deployments(
model_name=model, team_id=request_team_id