Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions litellm/proxy/management_endpoints/team_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -5153,6 +5153,7 @@ async def list_team_v2(
skip=skip,
take=page_size,
order=order_by if order_by else {"created_at": "desc"}, # Default sort
include=_INCLUDE_MODEL_TABLE,
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
)
# Get total count for pagination
total_count = await _deleted_team_db(prisma_client).count(where=where_conditions)
Expand All @@ -5162,6 +5163,7 @@ async def list_team_v2(
skip=skip,
take=page_size,
order=order_by if order_by else {"created_at": "desc"}, # Default sort
include=_INCLUDE_MODEL_TABLE,
)
# Get total count for pagination
total_count = await _team_db(prisma_client).count(where=where_conditions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3741,6 +3741,62 @@ async def test_list_team_v2_with_status_deleted():
assert len(result["teams"]) == 2


@pytest.mark.asyncio
async def test_list_team_v2_includes_litellm_model_table():
"""
Regression test for GH #26312: GET /v2/team/list must eagerly load the
litellm_model_table relation, same as /team/info and /team/list, or a
team's model_aliases always read back as null from this endpoint.
"""
from unittest.mock import AsyncMock, Mock, patch

from fastapi import Request

from litellm.proxy._types import LitellmUserRoles, UserAPIKeyAuth
from litellm.proxy.management_endpoints.team_endpoints import (
_INCLUDE_MODEL_TABLE,
list_team_v2,
)

mock_request = Mock(spec=Request)
mock_user_api_key_dict_admin = UserAPIKeyAuth(
user_role=LitellmUserRoles.PROXY_ADMIN,
user_id="admin_user_123",
)

with patch("litellm.proxy.proxy_server.prisma_client") as mock_prisma_client:
mock_db = Mock()
mock_prisma_client.db = mock_db

mock_db.litellm_teamtable.find_many = AsyncMock(return_value=[])
mock_db.litellm_teamtable.count = AsyncMock(return_value=0)

await list_team_v2(
http_request=mock_request,
user_id=None,
user_api_key_dict=mock_user_api_key_dict_admin,
page=1,
page_size=10,
status=None,
)

Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
assert mock_db.litellm_teamtable.find_many.call_args.kwargs["include"] == _INCLUDE_MODEL_TABLE

mock_db.litellm_deletedteamtable.find_many = AsyncMock(return_value=[])
mock_db.litellm_deletedteamtable.count = AsyncMock(return_value=0)

await list_team_v2(
http_request=mock_request,
user_id=None,
user_api_key_dict=mock_user_api_key_dict_admin,
page=1,
page_size=10,
status="deleted",
)

assert mock_db.litellm_deletedteamtable.find_many.call_args.kwargs["include"] == _INCLUDE_MODEL_TABLE


@pytest.mark.asyncio
async def test_list_team_v2_org_admin_sees_org_teams():
"""
Expand Down
Loading