From 304f0d9ad14b76abbfcb4bf11ed4435271ecbd99 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 14 Mar 2026 13:49:08 -0700 Subject: [PATCH] fix: make migration failure non-fatal by default, add --require_db_migration flag By default the proxy now warns and continues when database migration fails. Pass --require_db_migration (or set REQUIRE_DB_MIGRATION=true) to restore the previous behavior of exiting with an error. Co-Authored-By: Claude Opus 4.6 --- litellm/proxy/proxy_cli.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/litellm/proxy/proxy_cli.py b/litellm/proxy/proxy_cli.py index 153c3c2dba0..44a7c011df3 100644 --- a/litellm/proxy/proxy_cli.py +++ b/litellm/proxy/proxy_cli.py @@ -556,6 +556,13 @@ class ProxyInitializationHelpers: help="Restart worker after this many requests (uvicorn: limit_max_requests, gunicorn: max_requests)", envvar="MAX_REQUESTS_BEFORE_RESTART", ) +@click.option( + "--require_db_migration", + is_flag=True, + default=False, + help="Exit with error if database migration fails. By default the proxy will warn and continue.", + envvar="REQUIRE_DB_MIGRATION", +) def run_server( # noqa: PLR0915 host, port, @@ -595,6 +602,7 @@ def run_server( # noqa: PLR0915 skip_server_startup, keepalive_timeout, max_requests_before_restart, + require_db_migration: bool, ): args = locals() if local: @@ -857,11 +865,17 @@ def run_server( # noqa: PLR0915 if not PrismaManager.setup_database( use_migrate=not use_prisma_db_push ): - print( # noqa - "\033[1;31mLiteLLM Proxy: Database setup failed after multiple retries. " - "The proxy cannot start safely. Please check your database connection and migration status.\033[0m" - ) - sys.exit(1) + if require_db_migration: + print( # noqa + "\033[1;31mLiteLLM Proxy: Database setup failed after multiple retries. " + "The proxy cannot start safely. Please check your database connection and migration status.\033[0m" + ) + sys.exit(1) + else: + print( # noqa + "\033[1;33mLiteLLM Proxy: Database migration failed but continuing startup. " + "Use --require_db_migration to exit on migration failure.\033[0m" + ) else: print( # noqa f"Unable to connect to DB. DATABASE_URL found in environment, but prisma package not found." # noqa