(fix) allow gracefully handling DB connection errors on proxy (#7017)

* fix _handle_failed_db_connection_for_get_key_object

* _handle_failed_db_connection_for_get_key_object

* test_auth_not_connected_to_db
This commit is contained in:
Ishaan Jaff 2024-12-03 19:48:51 -08:00 committed by GitHub
parent c32a8caa5e
commit e499d39f9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 2 deletions

View file

@ -51,6 +51,7 @@ from litellm._service_logger import ServiceLogging
from litellm.proxy._types import *
from litellm.proxy.auth.auth_checks import (
_cache_key_object,
_handle_failed_db_connection_for_get_key_object,
allowed_routes_check,
can_key_call_model,
common_checks,
@ -802,7 +803,9 @@ async def user_api_key_auth( # noqa: PLR0915
if (
prisma_client is None
): # if both master key + user key submitted, and user key != master key, and no db connected, raise an error
raise Exception("No connected db.")
return await _handle_failed_db_connection_for_get_key_object(
e=Exception("No connected db.")
)
## check for cache hit (In-Memory Cache)
_user_role = None