fix(health): return structured response from webhook health check branch

The service == "webhook" branch of health_services_endpoint() called
proxy_logging_obj.budget_alerts() but had no return statement, so
execution fell through to the end of the function and implicitly
returned None. FastAPI serialized this as JSON `null` with HTTP 200,
unlike every other service branch which returns a structured
{"status": ..., "message": ...} dict.

Add the missing return so the webhook branch matches the response
shape used by the other branches, plus a regression test that mocks
budget_alerts and asserts both the call and the structured response.
This commit is contained in:
Will 2026-07-10 15:58:54 +01:00
parent bf02a4a47f
commit f04337030a
2 changed files with 31 additions and 0 deletions

View file

@ -332,6 +332,7 @@ async def health_services_endpoint(
type="user_budget",
user_info=user_info,
)
return {"status": "success", "message": "Mock webhook alert sent"}
elif service == "sqs":
from litellm.integrations.sqs import SQSLogger

View file

@ -265,6 +265,36 @@ async def test_health_services_endpoint_sqs(status, error_message):
mock_instance.async_health_check.assert_awaited_once()
@pytest.mark.asyncio
async def test_health_services_endpoint_webhook_returns_structured_response():
"""
Regression test: the /health/services webhook branch called
proxy_logging_obj.budget_alerts() but had no return statement, so
execution fell through to the end of the function and returned None
(serialized as JSON null with HTTP 200) instead of a structured
{"status": ..., "message": ...} dict like every other service branch.
"""
user_api_key_dict = UserAPIKeyAuth(
token="test-token",
user_id="test-user",
key_alias="test-key-alias",
team_id="test-team",
)
mock_budget_alerts = AsyncMock()
with patch(
"litellm.proxy.proxy_server.proxy_logging_obj.budget_alerts",
mock_budget_alerts,
):
result = await health_services_endpoint(
user_api_key_dict=user_api_key_dict,
service="webhook",
)
mock_budget_alerts.assert_awaited_once()
assert result == {"status": "success", "message": "Mock webhook alert sent"}
@pytest.mark.asyncio
async def test_health_license_endpoint_with_active_license():
license_data = {