BerriAI/litellm · error · RuntimeError

Database migration failed and cannot be auto-recovered. Manu

Error message

Database migration failed and cannot be auto-recovered. Manual intervention required.

Prisma error:
{stderr}

What it means

Terminal RuntimeError from the migration runner: a prisma migrate command failed and none of the automatic recovery paths (rollback, idempotent re-resolve) applied. The raw prisma stderr is embedded; the DB needs manual intervention.

Source

Thrown at litellm-proxy-extras/litellm_proxy_extras/utils.py:623

                            try:
                                ProxyExtrasDBManager._resolve_specific_migration(name)
                            except (
                                subprocess.CalledProcessError,
                                subprocess.TimeoutExpired,
                            ) as resolve_err:
                                # We're already inside the outer
                                # `except CalledProcessError` handler —
                                # re-raising CalledProcessError from here
                                # would escape as itself, bypassing
                                # proxy_cli.py's `except RuntimeError`.
                                raise RuntimeError(
                                    f"Failed to mark migration {name} as applied "
                                    f"after idempotent recovery. Manual "
                                    f"intervention may be required.\n\n"
                                    f"Detail: {resolve_err}"
                                ) from resolve_err
                            continue
                        raise RuntimeError(
                            "Database migration failed and cannot be auto-recovered. "
                            f"Manual intervention required.\n\nPrisma error:\n{stderr}"
                        ) from e

                    if "P3018" in stderr:
                        if ProxyExtrasDBManager._is_permission_error(stderr):
                            raise RuntimeError(
                                "Database migration failed due to insufficient "
                                "permissions. Please grant the required privileges "
                                f"and retry.\n\nPrisma error:\n{stderr}"
                            ) from e

                        migration_match = re.search(
                            r"Migration name: (\d+_\S+)", stderr
                        )
                        if (
                            migration_match
                            and ProxyExtrasDBManager._is_idempotent_error(stderr)

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Read the Prisma error in {stderr}; resolve the migration conflict manually (e.g. prisma migrate resolve) and retry.
  2. Restore from backup if the schema is in an inconsistent state.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm-proxy-extras/litellm_proxy_extras/utils.py:623 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/5aa7579673064b67. Report an issue: GitHub.