BerriAI/litellm · error · ValueError
Cannot parse IAM endpoint from URL: missing database name
Error message
Cannot parse IAM endpoint from URL: missing database name
What it means
Raised by parse_iam_endpoint_from_url when the Postgres URL has host and username but no database-name component (empty path). IAM token refresh needs the full database identity, not just the endpoint; a URL like postgres://user@host:5432/ (or without a path) is rejected. The host/username sibling check raises the neighbouring 'missing host or username' error.
Source
Thrown at litellm/proxy/db/prisma_client.py:155
try:
await self._engine.rollback_transaction(tx_id)
finally:
self.tracker.end_operation()
self.tracker.transaction_finished(tx_id)
def parse_iam_endpoint_from_url(url: str) -> IAMEndpoint:
"""Parse an IAMEndpoint from a Postgres URL.
Used so a reader URL can drive its own IAM refresh without requiring
callers to set parallel DATABASE_HOST_READ_REPLICA / etc. env vars.
"""
parsed: Final = urllib.parse.urlparse(url)
if not parsed.hostname or not parsed.username:
raise ValueError("Cannot parse IAM endpoint from URL: missing host or username")
name: Final = (parsed.path or "/").lstrip("/")
if not name:
raise ValueError("Cannot parse IAM endpoint from URL: missing database name")
port: Final = str(parsed.port) if parsed.port else "5432"
schema: str | None = None
if parsed.query:
qs: Final = urllib.parse.parse_qs(parsed.query)
schema_vals: Final = qs.get("schema")
if schema_vals:
schema = schema_vals[0]
return IAMEndpoint(
host=parsed.hostname,
port=port,
user=parsed.username,
name=name,
schema=schema,
)
class PrismaWrapper:
"""View on GitHub (pinned to 77b7c6c40c)
Solutions
- Include the database name in the URL path used for IAM auth.
Example fix
DATABASE_URL=postgresql://dbuser@host:5432/litellm
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/db/prisma_client.py:155 when the library encounters an invalid state.
Common situations: The IAM database URL is missing the database name segment.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/dd56c10386ddda36.
Report an issue: GitHub.