{"record":{"id":"e6e9aa626d859596","repo":"BerriAI/litellm","slug":"f-user-not-found-passed-user-id-user-id","errorCode":null,"errorMessage":"f\"User not found, passed user_id={user_id}\"","messagePattern":"f\"User not found, passed user_id=(.+?)\"","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"litellm/proxy/management_endpoints/internal_user_endpoints.py","lineNumber":2279,"sourceCode":"\n    # Batch-fetch target memberships once before the per-user loop. Avoids\n    # an N+1 DB call when delete_user is called with a large user_ids list.\n    target_org_ids_by_user: Final[dict[str, set]] = {}\n    if not caller_is_proxy_admin:\n        all_target_memberships: Final = await _organization_membership_table(prisma_client).find_many(\n            where={\"user_id\": {\"in\": data.user_ids}}\n        )\n        for m in all_target_memberships:\n            if not m.organization_id:\n                continue\n            target_org_ids_by_user.setdefault(m.user_id, set()).add(m.organization_id)\n\n    # check that all teams passed exist\n    for user_id in data.user_ids:\n        user_row = await UserRepository(prisma_client).table.find_unique(where={\"user_id\": user_id})\n\n        if user_row is None:\n            raise HTTPException(\n                status_code=404,\n                detail={\"error\": f\"User not found, passed user_id={user_id}\"},\n            )\n\n        if not caller_is_proxy_admin:\n            target_org_ids = target_org_ids_by_user.get(user_id, set())\n            # Org-admin may only delete users whose entire org membership is\n            # within their admin scope. A target with ANY org outside the\n            # caller's scope (or no org at all) requires PROXY_ADMIN.\n            if not target_org_ids or not target_org_ids.issubset(caller_admin_org_ids):\n                raise HTTPException(\n                    status_code=403,\n                    detail={\n                        \"error\": (\n                            f\"User {user_id} is not within your admin scope. \"\n                            \"Only PROXY_ADMIN may delete users outside your \"\n                            \"administered organizations.\"\n                        )","sourceCodeStart":2261,"sourceCodeEnd":2297,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/internal_user_endpoints.py#L2261-L2297","documentation":"Error \"f\"User not found, passed user_id={user_id}\"\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/internal_user_endpoints.py:2279 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the user_id exists via /user/list or /user/info before deleting.","Check for typos in the user_id value passed in the request."],"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-14T00:17:10.932Z"}