{"record":{"id":"a0607e98ae5ef51a","repo":"BerriAI/litellm","slug":"e-a0607e","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"litellm/proxy/management_endpoints/customer_endpoints.py","lineNumber":188,"sourceCode":"                record = await _typed_table(EndUserRepository(prisma_client)).upsert(\n                    where={\"user_id\": id},\n                    data={\n                        \"create\": {\"user_id\": id, \"blocked\": True},\n                        \"update\": {\"blocked\": True},\n                    },\n                )\n                records.append(record)\n            await _evict_end_user_cache_keys(_end_user_cache_keys(data.user_ids))\n        else:\n            raise HTTPException(\n                status_code=500,\n                detail={\"error\": \"Postgres DB Not connected\"},\n            )\n\n        return {\"blocked_users\": records}\n    except Exception as e:\n        verbose_proxy_logger.error(\"An error occurred - %s\", e)\n        raise HTTPException(status_code=500, detail={\"error\": str(e)})\n\n\n@router.post(\n    \"/end_user/unblock\",\n    tags=[\"Customer Management\"],\n    dependencies=[Depends(user_api_key_auth)],\n    include_in_schema=False,\n)\n@router.post(\n    \"/customer/unblock\",\n    tags=[\"Customer Management\"],\n    dependencies=[Depends(user_api_key_auth)],\n    response_model=UnblockUsersResponse,\n)\nasync def unblock_user(data: BlockUsers):\n    \"\"\"\n    [BETA] Unblock calls with this user id\n","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/customer_endpoints.py#L170-L206","documentation":"The catch-all handler at the bottom of POST /customer/block: any non-HTTPException error raised while upserting end-user rows or evicting end-user cache keys is logged via verbose_proxy_logger ('An error occurred - <e>') and re-raised as HTTP 500 whose detail is the original exception text. The catalog message '{e}' is dynamic - it mirrors whatever the underlying failure reported.","triggerScenarios":"Any unexpected exception inside the block loop: a Prisma query failure (constraint, connection drop, stale schema), an error while appending records, or a failure in _evict_end_user_cache_keys (e.g. Redis unreachable).","commonSituations":"Database restarted while blocking a batch of users; Prisma schema drift after upgrading the proxy image without applying migrations; cache backend (Redis) outage making cache eviction raise after the DB write already succeeded.","solutions":["Read the 500's detail string and the proxy log line 'An error occurred - ...' - they carry the real cause","If it is a DB error, restore connectivity and confirm migrations are applied, then retry","If it is cache eviction (Redis), fix or relax the cache backend and re-send the request","Re-send safely on recovery: each user_id is upserted, so partial progress is idempotent"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"import httpx\n\n\ndef block_users(base: str, headers: dict, user_ids: list[str]) -> dict:\n    r = httpx.post(f\"{base}/customer/block\", json={\"user_ids\": user_ids}, headers=headers)\n    if r.status_code >= 500:\n        detail = str(r.json().get(\"detail\", \"\"))  # raw underlying exception text\n        if \"Not connected\" in detail:\n            raise RuntimeError(\"proxy has no database configured\") from None\n        raise RuntimeError(f\"proxy internal error, check proxy logs: {detail}\")\n    r.raise_for_status()\n    return r.json()","preventionTips":["Treat any 500 from /customer/block as 'inspect proxy logs first' - the detail alone is often too terse","Keep DB schema in sync (run migrations) whenever you upgrade the LiteLLM proxy image","Make the cache backend failure-tolerant or monitored, since eviction errors surface as 500s here"],"tags":["litellm","catch-all","http-500","customer-management","database"],"backgroundTag":"internal-server-error","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}