BerriAI/litellm · error · Exception
DATABASE_URL not set
Error message
DATABASE_URL not set
What it means
Raised in check_prisma_schema_diff when no database URL is available: the passed db_url is None and the DATABASE_URL environment variable is unset. Prisma schema diffing requires a live database connection string; the proxy's migration check cannot run at all without it, hence the immediate ValueError.
Source
Thrown at litellm/proxy/db/check_migration.py:97
print("Changes to DB Schema detected") # noqa: T201
print("Required SQL commands:") # noqa: T201
for command in sql_commands:
print(command) # noqa: T201
return True, sql_commands
else:
return False, []
except subprocess.CalledProcessError as e:
error_message: Final = f"Failed to generate migration diff. Error: {e.stderr}"
print(error_message) # noqa: T201
return False, []
def check_prisma_schema_diff(db_url: str | None = None) -> None:
"""Main function to run the Prisma schema diff check."""
if db_url is None:
db_url = os.getenv("DATABASE_URL")
if db_url is None:
raise Exception("DATABASE_URL not set")
has_diff, message = check_prisma_schema_diff_helper(db_url)
if has_diff:
verbose_logger.exception(
"🚨🚨🚨 prisma schema out of sync with db. Consider running these sql_commands to sync the two - %s",
message,
)
View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set the DATABASE_URL environment variable before running the migration check.
Example fix
export DATABASE_URL=postgresql://user:pass@host:5432/litellm
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/db/check_migration.py:97 when the library encounters an invalid state.
Common situations: The migration check ran without DATABASE_URL configured.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/0b2c72a71e69c927.
Report an issue: GitHub.