fix(router): address remaining Greptile P0/P1 issues

- Update map_team_model test to expect public name return
- Only remove old public name if no sibling deployments use it

Made-with: Cursor
This commit is contained in:
Sameer Kankute 2026-03-23 16:33:26 +05:30
parent be4c9a52e8
commit 9e69a76d4f
No known key found for this signature in database
2 changed files with 30 additions and 12 deletions

View file

@ -472,14 +472,32 @@ 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,
)
from litellm.proxy.proxy_server import llm_router
other_deployments_with_old_name = []
if llm_router:
all_deployments = llm_router.get_model_list(
model_name=old_public_name, team_id=team_id
)
if all_deployments:
other_deployments_with_old_name = [
d
for d in all_deployments
if d.get("model_name") != db_model.model_name
and d.get("model_info", {}).get("team_public_model_name")
== old_public_name
]
if not other_deployments_with_old_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

@ -44,7 +44,7 @@ def test_map_team_model_should_not_iterate_aliases_for_non_alias_team_model_name
{f"alias-{idx}": "gpt-4" for idx in range(200)}
)
# map_team_model should return the public name unchanged (not the internal UUID name)
# so the router can find all sibling deployments via team_id filtering
result = router.map_team_model(team_model_name="team-model", team_id="team-1")
assert result == "team-model", f"Expected public name 'team-model', got {result}"
assert (
router.map_team_model(team_model_name="team-model", team_id="team-1")
== "team-model"
)