{"record":{"id":"83a7ba8027dacdb7","repo":"BerriAI/litellm","slug":"prisma-client-is-not-initialized-database-connect","errorCode":null,"errorMessage":"Prisma client is not initialized. Database connection required for LiteLLM skills.","messagePattern":"Prisma client is not initialized\\. Database connection required for LiteLLM skills\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/litellm_proxy/skills/handler.py","lineNumber":58,"sourceCode":"\n    data: Final = prisma_skill.model_dump()\n\n    if data.get(\"file_content\") is not None:\n        if isinstance(data[\"file_content\"], str):\n            data[\"file_content\"] = base64.b64decode(data[\"file_content\"])\n\n    return LiteLLM_SkillsTable(**data)\n\n\nclass LiteLLMSkillsHandler:\n    \"\"\"CRUD for skills stored in ``litellm_skillstable``.\"\"\"\n\n    @staticmethod\n    async def _get_prisma_client():\n        from litellm.proxy.proxy_server import prisma_client\n\n        if prisma_client is None:\n            raise ValueError(\"Prisma client is not initialized. Database connection required for LiteLLM skills.\")\n        return prisma_client\n\n    @staticmethod\n    async def create_skill(\n        data: NewSkillRequest,\n        user_id: str | None = None,\n        user_api_key_dict: UserAPIKeyAuth | None = None,\n    ) -> LiteLLM_SkillsTable:\n        prisma_client: Final = await LiteLLMSkillsHandler._get_prisma_client()\n\n        skill_id: Final = f\"{LITELLM_SKILL_ID_PREFIX}{uuid.uuid4()}\"\n        owner: Final = get_primary_resource_owner_scope(user_api_key_dict) or user_id\n        if owner is None:\n            # Identity-less callers (no user_id / team_id / org_id /\n            # api_key / token) can't be uniquely stamped on the row.\n            # Stamping a placeholder would let any two such callers see\n            # each other's skills via the shared owner. ValueError keeps\n            # this module FastAPI-free per the project layering rule.","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/litellm_proxy/skills/handler.py#L40-L76","documentation":"The LiteLLM Proxy skills feature persists custom skills in the litellm_skillstable via Prisma. Every handler operation first fetches the proxy server's prisma_client; if the server started without a DATABASE_URL (no Postgres), prisma_client is None and the handler raises ValueError. Skills CRUD is simply unavailable without a database.","triggerScenarios":"Calling any skills API endpoint (create/get/update/delete skill) on a LiteLLM proxy instance started without DATABASE_URL, so Prisma never initialized; database disabled via --disable_database or the equivalent config.","commonSituations":"Running the proxy in demo/local mode with no Postgres and then trying the skills routes; DATABASE_URL present but database connection failed at startup, leaving prisma_client None; test harness booting only part of the server.","solutions":["Configure a Postgres database: set DATABASE_URL in the proxy environment and restart so Prisma connects","Remove --disable_database / ensure the startup logs show a successful Prisma connection","Retry the skills request once the proxy logs confirm 'Prisma client connected'"],"exampleFix":"# before: proxy started without a DB\nlitellm --config config.yaml  # no DATABASE_URL\n\n# after\nexport DATABASE_URL=\"postgresql://user:pass@host:5432/litellm\"\nlitellm --config config.yaml","handlingStrategy":"try-catch","validationCode":"async def skills_available() -> bool:\n    from litellm.proxy.proxy_server import prisma_client\n    return prisma_client is not None","typeGuard":null,"tryCatchPattern":"try:\n    skill = await LiteLLMSkillsHandler.create_skill(data=payload, user_api_key_dict=auth)\nexcept ValueError as e:\n    if \"Prisma client is not initialized\" in str(e):\n        raise RuntimeError(\"Skills require a Postgres DB: set DATABASE_URL and restart the proxy\") from e","preventionTips":["Treat a missing DATABASE_URL as a hard config error at proxy startup if skills are in scope","Gate skills routes/features on a startup probe that prisma_client is not None","Watch proxy boot logs for Prisma connection success before running skills integration tests"],"tags":["litellm-proxy","database","skills","prisma"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}