mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-06 07:08:05 +00:00
fix(enterprise): correct error message for DISABLE_ADMIN_ENDPOINTS (#19861)
The error message for DISABLE_ADMIN_ENDPOINTS incorrectly said "DISABLING LLM API ENDPOINTS is an Enterprise feature" instead of "DISABLING ADMIN ENDPOINTS is an Enterprise feature". This was a copy-paste bug from the is_llm_api_route_disabled() function. Added regression tests to verify both error messages are correct.
This commit is contained in:
@@ -36,7 +36,7 @@ class EnterpriseRouteChecks:
|
||||
if not premium_user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"🚨🚨🚨 DISABLING LLM API ENDPOINTS is an Enterprise feature\n🚨 {CommonProxyErrors.not_premium_user.value}",
|
||||
detail=f"🚨🚨🚨 DISABLING ADMIN ENDPOINTS is an Enterprise feature\n🚨 {CommonProxyErrors.not_premium_user.value}",
|
||||
)
|
||||
|
||||
return get_secret_bool("DISABLE_ADMIN_ENDPOINTS") is True
|
||||
|
||||
@@ -180,3 +180,68 @@ class TestEnterpriseRouteChecks:
|
||||
|
||||
# Should not raise exception since management routes are enabled
|
||||
EnterpriseRouteChecks.should_call_route("/config/update")
|
||||
|
||||
|
||||
class TestEnterpriseRouteChecksErrorMessages:
|
||||
"""Test that error messages correctly identify which feature requires Enterprise license"""
|
||||
|
||||
@patch("litellm.secret_managers.main.get_secret_bool")
|
||||
@patch("litellm.proxy.proxy_server.premium_user", False)
|
||||
def test_disable_llm_api_endpoints_error_message(self, mock_get_secret_bool):
|
||||
"""
|
||||
Test that when DISABLE_LLM_API_ENDPOINTS is set without Enterprise license,
|
||||
the error message correctly mentions 'LLM API ENDPOINTS'
|
||||
"""
|
||||
with patch.dict(os.environ, {"DISABLE_LLM_API_ENDPOINTS": "true"}):
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
EnterpriseRouteChecks.is_llm_api_route_disabled()
|
||||
|
||||
assert exc_info.value.status_code == 500
|
||||
assert "DISABLING LLM API ENDPOINTS is an Enterprise feature" in str(
|
||||
exc_info.value.detail
|
||||
)
|
||||
|
||||
@patch("litellm.secret_managers.main.get_secret_bool")
|
||||
@patch("litellm.proxy.proxy_server.premium_user", False)
|
||||
def test_disable_admin_endpoints_error_message(self, mock_get_secret_bool):
|
||||
"""
|
||||
Test that when DISABLE_ADMIN_ENDPOINTS is set without Enterprise license,
|
||||
the error message correctly mentions 'ADMIN ENDPOINTS' (not 'LLM API ENDPOINTS')
|
||||
|
||||
This is a regression test for a bug where the error message incorrectly said
|
||||
'DISABLING LLM API ENDPOINTS' when the actual issue was DISABLE_ADMIN_ENDPOINTS.
|
||||
"""
|
||||
with patch.dict(os.environ, {"DISABLE_ADMIN_ENDPOINTS": "true"}):
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
EnterpriseRouteChecks.is_management_routes_disabled()
|
||||
|
||||
assert exc_info.value.status_code == 500
|
||||
assert "DISABLING ADMIN ENDPOINTS is an Enterprise feature" in str(
|
||||
exc_info.value.detail
|
||||
)
|
||||
# Ensure it does NOT mention LLM API ENDPOINTS (the old buggy message)
|
||||
assert "LLM API ENDPOINTS" not in str(exc_info.value.detail)
|
||||
|
||||
@patch("litellm.secret_managers.main.get_secret_bool")
|
||||
@patch("litellm.proxy.proxy_server.premium_user", True)
|
||||
def test_disable_llm_api_endpoints_with_premium_user(self, mock_get_secret_bool):
|
||||
"""
|
||||
Test that premium users can use DISABLE_LLM_API_ENDPOINTS without error
|
||||
"""
|
||||
mock_get_secret_bool.return_value = True
|
||||
with patch.dict(os.environ, {"DISABLE_LLM_API_ENDPOINTS": "true"}):
|
||||
# Should not raise exception for premium users
|
||||
result = EnterpriseRouteChecks.is_llm_api_route_disabled()
|
||||
assert result is True
|
||||
|
||||
@patch("litellm.secret_managers.main.get_secret_bool")
|
||||
@patch("litellm.proxy.proxy_server.premium_user", True)
|
||||
def test_disable_admin_endpoints_with_premium_user(self, mock_get_secret_bool):
|
||||
"""
|
||||
Test that premium users can use DISABLE_ADMIN_ENDPOINTS without error
|
||||
"""
|
||||
mock_get_secret_bool.return_value = True
|
||||
with patch.dict(os.environ, {"DISABLE_ADMIN_ENDPOINTS": "true"}):
|
||||
# Should not raise exception for premium users
|
||||
result = EnterpriseRouteChecks.is_management_routes_disabled()
|
||||
assert result is True
|
||||
|
||||
Reference in New Issue
Block a user