{"record":{"id":"4750be1786f689b0","repo":"BerriAI/litellm","slug":"only-proxy-admins-can-patch-prompts","errorCode":null,"errorMessage":"Only proxy admins can patch prompts","messagePattern":"Only proxy admins can patch prompts","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"litellm/proxy/prompts/prompt_endpoints.py","lineNumber":1084,"sourceCode":"        -H \"Authorization: Bearer <your_api_key>\" \\\\\n        -H \"Content-Type: application/json\" \\\\\n        -d '{\n            \"prompt_info\": {\n                \"prompt_type\": \"db\"\n            }\n        }'\n    ```\n    \"\"\"\n\n    from litellm.proxy.prompts.prompt_registry import IN_MEMORY_PROMPT_REGISTRY\n    from litellm.proxy.proxy_server import prisma_client\n\n    # Only allow proxy admins to patch prompts\n    if user_api_key_dict.user_role is None or (\n        user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN\n        and user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN.value\n    ):\n        raise HTTPException(status_code=403, detail=\"Only proxy admins can patch prompts\")\n\n    if prisma_client is None:\n        raise HTTPException(status_code=500, detail=CommonProxyErrors.db_not_connected_error.value)\n\n    try:\n        # Resolve the target row: find the latest version in the given environment\n        base_prompt_id: Final = get_base_prompt_id(prompt_id=prompt_id)\n        env: Final = environment or \"development\"\n        requested_version: Final = get_version_number(prompt_id=prompt_id) if prompt_id != base_prompt_id else None\n\n        # Build query to find the exact row by composite unique key\n        find_where: Final[dict[str, str | int]] = {\n            \"prompt_id\": base_prompt_id,\n            \"environment\": env,\n        }\n        if requested_version is not None:\n            find_where[\"version\"] = requested_version\n","sourceCodeStart":1066,"sourceCodeEnd":1102,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/prompts/prompt_endpoints.py#L1066-L1102","documentation":"Authorization gate on prompt patching: the caller's user_api_key_dict lacks the PROXY_ADMIN role, so partial updates are rejected before any prompt row is read or merged.","triggerScenarios":"Thrown at litellm/proxy/prompts/prompt_endpoints.py:1084 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a proxy admin key to patch prompts."],"exampleFix":null,"handlingStrategy":"validation","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-14T05:17:10.506Z"}