mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
fix(proxy): list directly assigned team models in model access errors
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
c8114ba41f
commit
56d0f953f5
2 changed files with 26 additions and 1 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
"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()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue