From 70ebdeec8ba6c1c1544b0eb043d2b1343fbf660b Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Sat, 7 Feb 2026 16:44:29 -0800 Subject: [PATCH 1/2] modernize /team/available endpoint, migrate link to UI --- .../management_endpoints/team_endpoints.py | 7 +--- .../test_team_endpoints.py | 35 +++++++++++++++++++ .../src/components/team/available_teams.tsx | 11 +++++- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.py index 8e903180ac5..b45ac26a9ee 100644 --- a/litellm/proxy/management_endpoints/team_endpoints.py +++ b/litellm/proxy/management_endpoints/team_endpoints.py @@ -3095,12 +3095,7 @@ async def list_available_teams( ), ) if available_teams is None: - raise HTTPException( - status_code=400, - detail={ - "error": "No available teams for user to join. See how to set available teams here: https://docs.litellm.ai/docs/proxy/self_serve#all-settings-for-self-serve--sso-flow" - }, - ) + return [] # filter out teams that the user is already a member of user_info = await prisma_client.db.litellm_usertable.find_unique( diff --git a/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py b/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py index 7e351e29168..c4c953b75fb 100644 --- a/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py +++ b/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py @@ -38,6 +38,7 @@ from litellm.proxy.management_endpoints.team_endpoints import ( _transform_teams_to_deleted_records, _validate_and_populate_member_user_info, delete_team, + list_available_teams, router, team_member_add_duplication_check, team_member_delete, @@ -5871,3 +5872,37 @@ async def test_validate_and_populate_member_user_info_only_user_id_not_found(): mock_prisma_client.db.litellm_usertable.find_unique.assert_called_once_with( where={"user_id": "nonexistent-user"} ) + + +@pytest.mark.asyncio +async def test_list_available_teams_returns_empty_list_when_none_configured(): + """ + Test that /team/available returns an empty list when no available teams + are configured, instead of raising an exception. + """ + import litellm + + mock_request = MagicMock() + mock_user_key = UserAPIKeyAuth(user_id="test-user", token="fake-token") + + with patch( + "litellm.proxy.proxy_server.prisma_client", mock_prisma_client + ): + # Case 1: default_internal_user_params is None + original = litellm.default_internal_user_params + litellm.default_internal_user_params = None + result = await list_available_teams( + http_request=mock_request, + user_api_key_dict=mock_user_key, + ) + assert result == [] + + # Case 2: default_internal_user_params exists but has no "available_teams" key + litellm.default_internal_user_params = {"some_other_param": "value"} + result = await list_available_teams( + http_request=mock_request, + user_api_key_dict=mock_user_key, + ) + assert result == [] + + litellm.default_internal_user_params = original diff --git a/ui/litellm-dashboard/src/components/team/available_teams.tsx b/ui/litellm-dashboard/src/components/team/available_teams.tsx index d4a172e8d01..34dcd126714 100644 --- a/ui/litellm-dashboard/src/components/team/available_teams.tsx +++ b/ui/litellm-dashboard/src/components/team/available_teams.tsx @@ -113,7 +113,16 @@ const AvailableTeamsPanel: React.FC = ({ accessToken, userI {availableTeams.length === 0 && ( - No available teams to join + No available teams to join. See how to set available teams{" "} + + here + . + )} From 78f28d7c303f332c3f0f5f4f77213b9b47f55006 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Sat, 7 Feb 2026 16:46:11 -0800 Subject: [PATCH 2/2] adding test --- .../src/components/team/available_teams.test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/src/components/team/available_teams.test.tsx b/ui/litellm-dashboard/src/components/team/available_teams.test.tsx index af2a0247b47..254a5a9bc8e 100644 --- a/ui/litellm-dashboard/src/components/team/available_teams.test.tsx +++ b/ui/litellm-dashboard/src/components/team/available_teams.test.tsx @@ -58,7 +58,8 @@ describe("AvailableTeamsPanel", () => { renderWithProviders(); await waitFor(() => { - expect(screen.getByText("No available teams to join")).toBeInTheDocument(); + expect(screen.getByText(/No available teams to join/i)).toBeInTheDocument(); + expect(screen.getByText(/See how to set available teams/i)).toBeInTheDocument(); }); });