BerriAI/litellm · error · Exception

Error updating policy in DB

Error message

Error updating policy in DB: {e}

What it means

Catch-all from the policy update routine: building the update payload (including GuardrailPipeline validation and JSON serialization of condition/pipeline) or executing the Prisma update failed; the original exception is embedded in the message.

Solutions

  1. Check DB connectivity and logs for the underlying error, then retry the update.
Defensive patterns

Strategy: try-catch

When it happens

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

Appendix: source

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

            if policy_request.guardrails_remove is not None:
                update_data["guardrails_remove"] = policy_request.guardrails_remove
            if policy_request.condition is not None:
                update_data["condition"] = json.dumps(policy_request.condition.model_dump())
            if policy_request.pipeline is not None:
                validated_pipeline: Final = GuardrailPipeline(**policy_request.pipeline)
                update_data["pipeline"] = json.dumps(validated_pipeline.model_dump())

            updated_policy: Final = await _policy_table(prisma_client).update(
                where={"policy_id": policy_id},
                data=update_data,
            )

            # Do NOT update in-memory registry: drafts are not loaded into memory.

            return _row_to_policy_db_response(updated_policy)
        except Exception as e:
            verbose_proxy_logger.exception("Error updating policy in DB: %s", e)
            raise Exception(f"Error updating policy in DB: {e}")

    async def delete_policy_from_db(
        self,
        policy_id: str,
        prisma_client: "PrismaClient",
    ) -> Mapping[str, str]:
        """
        Delete a policy version from the database.

        If the deleted version was production, it is removed from the in-memory
        registry. No other version is auto-promoted; admin must explicitly promote.

        Args:
            policy_id: The ID of the policy version to delete
            prisma_client: The Prisma client instance

        Returns:
            Dict with "message" and optional "warning" if production was deleted.

View on GitHub (pinned to 77b7c6c40c)