This commit is contained in:
David Koh 2026-10-19 19:55:47 +00:00 • committed by GitHub
commit 136e18d7e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 1 deletions

View file

@ -653,7 +653,16 @@ async def new_project(
verbose_proxy_logger.exception(
"litellm.proxy.management_endpoints.project_endpoints.new_project(): Exception occured - {}".format(str(e))
)
raise handle_exception_on_proxy(e)
proxy_exception: Final[ProxyException] = handle_exception_on_proxy(e)
if proxy_exception.code == "500":
raise ProxyException(
message="Internal server error",
type="internal_server_error",
param=None,
code=500,
headers=proxy_exception.headers,
) from e
raise proxy_exception
@router.post(

View file

@ -1238,6 +1238,34 @@ async def test_new_project_flag_on_missing_rpm_tpm_returns_400(monkeypatch):
assert "rpm/tpm quota" in str(exc_info.value)
@pytest.mark.asyncio
async def test_new_project_does_not_expose_database_errors(monkeypatch):
internal_detail = "db-internal-marker"
mock_prisma_client = mock.MagicMock()
mock_prisma_client.db.litellm_teamtable.find_unique = mock.AsyncMock(side_effect=RuntimeError(internal_detail))
monkeypatch.setattr(litellm.proxy.proxy_server, "prisma_client", mock_prisma_client)
monkeypatch.setattr(litellm.proxy.proxy_server, "premium_user", True)
monkeypatch.setattr(litellm.proxy.proxy_server, "general_settings", {})
with pytest.raises(ProxyException) as exc_info:
await _run_new_project(NewProjectRequest(team_id="test-team"))
assert exc_info.value.code == "500"
assert exc_info.value.message
assert internal_detail not in exc_info.value.message
@pytest.mark.asyncio
async def test_new_project_keeps_license_error(monkeypatch):
monkeypatch.setattr(litellm.proxy.proxy_server, "premium_user", False)
with pytest.raises(ProxyException) as exc_info:
await _run_new_project(NewProjectRequest(team_id="test-team"))
assert exc_info.value.code == "403"
assert "enterprise feature" in exc_info.value.message
def _project_update_mocks(monkeypatch, stored_metadata: dict) -> mock.MagicMock:
existing_row = mock.MagicMock(
team_id=None, budget_id=None, object_permission_id=None, metadata=stored_metadata