Skip to content

Commit 834f50b

Browse files
authored
nit: adding logging in case read replica is not initialized in litellm (#178)
1 parent 0db3527 commit 834f50b

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

litellm/proxy/spend_tracking/spend_management_endpoints.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,19 @@ def _get_read_prisma_client():
4040
"""Get the read replica Prisma client, falling back to primary if not configured."""
4141
from litellm.proxy.proxy_server import prisma_client, prisma_read_client
4242

43-
client = prisma_read_client if prisma_read_client is not None else prisma_client
44-
if client is None:
43+
if prisma_read_client is not None:
44+
return prisma_read_client
45+
46+
print("[WARNING] Read replica not initialized (READ_DATABASE_URL not set), falling back to primary DATABASE_URL")
47+
48+
if prisma_client is None:
4549
raise ProxyException(
4650
message="Database not connected. Connect a database to your proxy - https://docs.litellm.ai/docs/simple_proxy#managing-auth---virtual-keys",
4751
type="internal_error",
4852
param="None",
4953
code=status.HTTP_500_INTERNAL_SERVER_ERROR,
5054
)
51-
return client
55+
return prisma_client
5256

5357

5458
class ErrorStatsResponse(BaseModel):

0 commit comments

Comments
 (0)