Merge pull request #41256 from BerriAI/litellm_team_model_access_error_lists_all_models

fix(proxy): list directly assigned team models in model access errors
This commit is contained in:
Yassin Kortam 2026-09-15 11:16:25 -07:00 committed by GitHub
commit dfcefd8298
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View file

@ -4659,7 +4659,7 @@ async def can_team_access_model(
return _can_object_call_model(
model=model,
llm_router=llm_router,
models=models_from_groups,
models=list(dict.fromkeys([*(team_object.models if team_object else []), *models_from_groups])),
team_model_aliases=team_model_aliases,
team_id=team_object.team_id if team_object else None,
object_type="team",

View file

@ -513,6 +513,31 @@ async def test_can_team_access_model_all_team_models_expands_router_models():
assert exc_info.value.type == ProxyErrorTypes.team_model_access_denied
@pytest.mark.asyncio
async def test_can_team_access_model_error_lists_direct_and_access_group_models():
from litellm.proxy.auth.auth_checks import can_team_access_model
team_object = LiteLLM_TeamTable(
team_id="team-123",
models=["direct-model"],
access_group_ids=["ag-1"],
)
with patch( # test-quality-ok: access-group lookup has no dependency-injection seam
"litellm.proxy.auth.auth_checks._get_models_from_access_groups",
new=AsyncMock(return_value=["group-model"]),
):
assert await can_team_access_model("direct-model", team_object, None) is True
assert await can_team_access_model("group-model", team_object, None) is True
with pytest.raises(ProxyException) as exc_info:
await can_team_access_model("blocked-model", team_object, None)
assert exc_info.value.type == ProxyErrorTypes.team_model_access_denied
assert "direct-model" in exc_info.value.message
assert "group-model" in exc_info.value.message
@pytest.mark.asyncio
async def test_get_key_object_should_reconnect_once_on_db_connection_error():
mock_prisma_client = MagicMock()