{"record":{"id":"0d5364187abdafbd","repo":"BerriAI/litellm","slug":"error-creating-new-version-e","errorCode":null,"errorMessage":"Error creating new version: {e}","messagePattern":"Error creating new version: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_registry.py","lineNumber":855,"sourceCode":"                \"guardrails_remove\": source.guardrails_remove or [],\n                \"created_at\": now,\n                \"updated_at\": now,\n                \"created_by\": created_by,\n                \"updated_by\": created_by,\n            }\n            # Prisma expects Json fields as JSON strings on create (same as add_policy_to_db)\n            if source.condition is not None:\n                data[\"condition\"] = (\n                    json.dumps(source.condition) if isinstance(source.condition, dict) else source.condition\n                )\n            if source.pipeline is not None:\n                data[\"pipeline\"] = json.dumps(source.pipeline) if isinstance(source.pipeline, dict) else source.pipeline\n\n            created: Final = await _policy_table(prisma_client).create(data=data)\n            return _row_to_policy_db_response(created)\n        except Exception as e:\n            verbose_proxy_logger.exception(\"Error creating new version: %s\", e)\n            raise Exception(f\"Error creating new version: {e}\")\n\n    async def update_version_status(\n        self,\n        policy_id: str,\n        new_status: str,\n        prisma_client: \"PrismaClient\",\n        updated_by: str | None = None,\n    ) -> PolicyDBResponse:\n        \"\"\"\n        Update a policy version's status. Valid transitions:\n        - draft -> published (sets published_at)\n        - published -> production (sets production_at, demotes current production to published, updates in-memory)\n        - production -> published (demotes, removes from in-memory)\n        - draft -> production: NOT allowed (must publish first)\n        - published -> draft: NOT allowed\n\n        Args:\n            policy_id: The policy version ID","sourceCodeStart":837,"sourceCodeEnd":873,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_registry.py#L837-L873","documentation":"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.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_registry.py:855 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the error detail and DB connectivity; fix the version payload and retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}