diff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.py index 3a77f163251..fdd44c16799 100644 --- a/litellm/proxy/management_endpoints/team_endpoints.py +++ b/litellm/proxy/management_endpoints/team_endpoints.py @@ -76,6 +76,7 @@ from litellm.proxy._types import ( ) from litellm.proxy.auth.auth_checks import ( OrganizationNotFoundError, + UserNotFoundError, _cache_team_object, allowed_route_check_inside_route, can_org_access_model, @@ -4873,7 +4874,7 @@ async def _get_user_team_ids_from_db( proxy_logging_obj=proxy_logging_obj, check_db_only=True, ) - except ValueError: + except UserNotFoundError: return () return tuple(user.teams or ()) if user is not None else () 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 82137f7861e..ccb66fd9534 100644 --- a/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py +++ b/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py @@ -4204,6 +4204,10 @@ async def test_list_team_v2_org_admin_own_query_keeps_memberships_in_other_orgs( where={"user_id": "org_admin_user"}, include={"organization_memberships": True} ) + prisma_client.db.litellm_usertable.find_unique.side_effect = RuntimeError("db down") + with pytest.raises(ValueError, match="db down"): + await list_teams("org_admin_user") + @pytest.mark.asyncio async def test_list_team_v1_org_admin_own_query_keeps_memberships_in_other_orgs():