From 7cc27a72cd1fd5c2b669ecb72d23f92c6058275e Mon Sep 17 00:00:00 2001 From: Harshit28j Date: Mon, 16 Mar 2026 18:04:36 +0530 Subject: [PATCH] fix: only fail hard on diff application error when marking all as applied The _resolve_all_migrations sanity check path (mark_all_applied=False) should warn on diff failure, not crash. Only the P3005 baselining path (mark_all_applied=True) should fail hard to prevent marking all migrations as applied when the diff wasn't applied. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../litellm_proxy_extras/utils.py | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/litellm-proxy-extras/litellm_proxy_extras/utils.py b/litellm-proxy-extras/litellm_proxy_extras/utils.py index cdc8c95972a..dc66b1979f5 100644 --- a/litellm-proxy-extras/litellm_proxy_extras/utils.py +++ b/litellm-proxy-extras/litellm_proxy_extras/utils.py @@ -325,20 +325,26 @@ class ProxyExtrasDBManager: logger.info(f"prisma db execute stdout: {result.stdout}") logger.info("✅ Migration diff applied successfully") except subprocess.CalledProcessError as e: - logger.error( - f"Failed to apply migration diff: {e.stderr}. " - f"Will NOT mark migrations as applied." - ) - raise RuntimeError( - f"Migration diff application failed. Migrations will not be marked as applied. " - f"Please check the database state and apply the diff manually. Error: {e.stderr}" - ) from e + if mark_all_applied: + logger.error( + f"Failed to apply migration diff: {e.stderr}. " + f"Will NOT mark migrations as applied." + ) + raise RuntimeError( + f"Migration diff application failed. Migrations will not be marked as applied. " + f"Please check the database state and apply the diff manually. Error: {e.stderr}" + ) from e + else: + logger.warning(f"Failed to apply migration diff: {e.stderr}") except subprocess.TimeoutExpired: - logger.error("Migration diff application timed out. Will NOT mark migrations as applied.") - raise RuntimeError( - "Migration diff application timed out. Migrations will not be marked as applied. " - "Please check the database state and apply the diff manually." - ) + if mark_all_applied: + logger.error("Migration diff application timed out. Will NOT mark migrations as applied.") + raise RuntimeError( + "Migration diff application timed out. Migrations will not be marked as applied. " + "Please check the database state and apply the diff manually." + ) + else: + logger.warning("Migration diff application timed out.") # 3. Mark all migrations as applied if not mark_all_applied: