BerriAI/litellm · error · Exception

Error creating new version: {e}

Error message

Error creating new version: {e}

What it means

Catch-all from the create-new-version routine: assembling the cloned row data (including JSON serialization of condition/pipeline) or the Prisma create of the draft failed; the original exception is embedded.

Source

Thrown at litellm/proxy/policy_engine/policy_registry.py:855

                "guardrails_remove": source.guardrails_remove or [],
                "created_at": now,
                "updated_at": now,
                "created_by": created_by,
                "updated_by": created_by,
            }
            # Prisma expects Json fields as JSON strings on create (same as add_policy_to_db)
            if source.condition is not None:
                data["condition"] = (
                    json.dumps(source.condition) if isinstance(source.condition, dict) else source.condition
                )
            if source.pipeline is not None:
                data["pipeline"] = json.dumps(source.pipeline) if isinstance(source.pipeline, dict) else source.pipeline

            created: Final = await _policy_table(prisma_client).create(data=data)
            return _row_to_policy_db_response(created)
        except Exception as e:
            verbose_proxy_logger.exception("Error creating new version: %s", e)
            raise Exception(f"Error creating new version: {e}")

    async def update_version_status(
        self,
        policy_id: str,
        new_status: str,
        prisma_client: "PrismaClient",
        updated_by: str | None = None,
    ) -> PolicyDBResponse:
        """
        Update a policy version's status. Valid transitions:
        - draft -> published (sets published_at)
        - published -> production (sets production_at, demotes current production to published, updates in-memory)
        - production -> published (demotes, removes from in-memory)
        - draft -> production: NOT allowed (must publish first)
        - published -> draft: NOT allowed

        Args:
            policy_id: The policy version ID

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check the error detail and DB connectivity; fix the version payload and retry.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/policy_engine/policy_registry.py:855 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/0d5364187abdafbd. Report an issue: GitHub.