{"record":{"id":"cccad03134dd8816","repo":"BerriAI/litellm","slug":"cannot-authorize-spend-log-access-without-a-databa","errorCode":null,"errorMessage":"Cannot authorize spend log access without a database connection. Connect a database or use a proxy admin key.","messagePattern":"Cannot authorize spend log access without a database connection\\. Connect a database or use a proxy admin key\\.","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"litellm/proxy/spend_tracking/spend_management_endpoints.py","lineNumber":2778,"sourceCode":"        description=\"Time from which to start viewing key spend\",\n    ),\n    end_date: str | None = fastapi.Query(\n        default=None,\n        description=\"Time till which to view key spend\",\n    ),\n    user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),\n):\n    \"\"\"\n    View request / response for a specific request_id\n\n    - goes through all callbacks, checks if any of them have a @property -> has_request_response_payload\n    - if so, it will return the request and response payload\n    \"\"\"\n    from litellm.proxy.proxy_server import prisma_client\n\n    if not _is_admin_view_safe(user_api_key_dict=user_api_key_dict):\n        if prisma_client is None:\n            raise HTTPException(\n                status_code=status.HTTP_403_FORBIDDEN,\n                detail={\n                    \"error\": (\n                        \"Cannot authorize spend log access without a database \"\n                        \"connection. Connect a database or use a proxy admin key.\"\n                    )\n                },\n            )\n        await _assert_user_can_view_request_id(\n            prisma_client=prisma_client,\n            user_api_key_dict=user_api_key_dict,\n            request_id=request_id,\n        )\n\n    custom_loggers: Final = litellm.logging_callback_manager.get_active_additional_logging_utils_from_custom_logger()\n    start_date_obj: datetime | None = None\n    end_date_obj: datetime | None = None\n    if start_date is not None:","sourceCodeStart":2760,"sourceCodeEnd":2796,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/spend_tracking/spend_management_endpoints.py#L2760-L2796","documentation":"Error \"Cannot authorize spend log access without a database connection. Connect a database or use a proxy admin key.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/spend_tracking/spend_management_endpoints.py:2778 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Connect a database by setting DATABASE_URL to a PostgreSQL connection string and restarting the proxy.","Alternatively use a proxy admin key (master key) to authorize spend log access without a database."],"exampleFix":null,"handlingStrategy":null,"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"}