fix(router): reject ambiguous admin team model pools

This commit is contained in:
kunal2002 2026-07-12 00:22:01 +05:30 • committed by ryan-crabbe-berri
parent 71eb0b988b
commit 97a4a5f9a8
3 changed files with 45 additions and 2 deletions

View file

@ -10053,8 +10053,8 @@ class Router:
if len(team_ids) > 1:
raise litellm.BadRequestError(
message=(
f"Team-scoped model name '{model}' is configured for multiple teams. "
"Pass a team context or deployment ID to select one."
f"Model name '{model}' matches deployments from multiple teams. "
"Specify the deployment ID directly to disambiguate."
),
model=model,
llm_provider="",

View file

@ -6,6 +6,7 @@ from typing import TYPE_CHECKING, Dict, List, Optional, Union
if TYPE_CHECKING:
from litellm.types.llms.openai import OpenAIFileObject
from litellm.exceptions import BadRequestError
from litellm.types.router import CredentialLiteLLMParams
from litellm._logging import verbose_logger
@ -78,6 +79,25 @@ def filter_team_based_models(
candidate_model_info = tuple(
model_info for deployment in healthy_deployments for model_info in [deployment.get("model_info") or {}]
)
team_ids = frozenset(
team_id
for model_info in candidate_model_info
for team_id in [model_info.get("team_id")]
if team_id is not None
)
if (
isinstance(requested_model, str)
and len(team_ids) > 1
and all(model_info.get("team_public_model_name") == requested_model for model_info in candidate_model_info)
):
raise BadRequestError(
message=(
f"Model name '{requested_model}' matches deployments from multiple teams. "
"Specify the deployment ID directly to disambiguate."
),
model=requested_model,
llm_provider="",
)
if (
isinstance(requested_model, str)
and candidate_model_info

View file

@ -167,6 +167,29 @@ async def test_route_request_proxy_admin_can_call_all_team_scoped_deployments_wi
},
)
)
router.add_deployment(
Deployment(
model_name="team-azure",
litellm_params={
"model": "azure/gpt-4o",
"api_key": "fake",
"api_base": "https://other-legacy.example.openai.azure.com",
"api_version": "2024-02-15-preview",
},
model_info={
"id": "other-legacy-team-azure",
"team_id": "team-b",
"team_public_model_name": "team-azure",
},
)
)
with pytest.raises(litellm.BadRequestError, match="multiple teams"):
await router.async_get_healthy_deployments(
model="team-azure",
request_kwargs=data,
)
router.add_deployment(
Deployment(
model_name="team-azure",