{"record":{"id":"69178e53d6b64038","repo":"BerriAI/litellm","slug":"error-finding-organization-membership-for-user-id","errorCode":null,"errorMessage":"Error finding organization membership for user_id={data.user_id} in organization={data.organization_id}: {e}","messagePattern":"Error finding organization membership for user_id=(.+?) in organization=(.+?): (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/management_endpoints/organization_endpoints.py","lineNumber":1356,"sourceCode":"\n        # Check if member exists in organization\n        if data.user_email is not None and data.user_id is None:\n            existing_user_email_row: Final = await find_member_if_email(data.user_email, prisma_client)\n            data.user_id = existing_user_email_row.user_id\n\n        try:\n            existing_organization_membership: Final = await _table(\n                OrganizationMembershipRepository(prisma_client)\n            ).find_unique(\n                where={\n                    \"user_id_organization_id\": {\n                        \"user_id\": data.user_id,\n                        \"organization_id\": data.organization_id,\n                    }\n                }\n            )\n        except Exception as e:\n            raise HTTPException(\n                status_code=400,\n                detail={\n                    \"error\": f\"Error finding organization membership for user_id={data.user_id} in organization={data.organization_id}: {e}\"\n                },\n            )\n        if existing_organization_membership is None:\n            raise HTTPException(\n                status_code=404,\n                detail={\"error\": f\"Member not found in organization for user_id={data.user_id}\"},\n            )\n\n        # Reject attempts to change the role of a global PROXY_ADMIN via\n        # org-scoped operations. An org-admin of any org could otherwise\n        # alter a PROXY_ADMIN user's per-org role, which has downstream\n        # effects on admin UI filtering and scope derivation.\n        target_user_row = await _table(UserRepository(prisma_client)).find_unique(where={\"user_id\": data.user_id})\n        if target_user_row is not None and getattr(target_user_row, \"user_role\", None) in (\n            LitellmUserRoles.PROXY_ADMIN.value,","sourceCodeStart":1338,"sourceCodeEnd":1374,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/organization_endpoints.py#L1338-L1374","documentation":"While removing/updating a member, the lookup of the (user_id, organization_id) pair in the organization membership table threw — typically a Prisma/DB connectivity or query error, not a simple absence. The endpoint converts it into a 400 so the client sees which user/org pair could not be resolved.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/organization_endpoints.py:1356 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the user_id is a member of the organization.","Check proxy server logs for the underlying exception."],"exampleFix":null,"handlingStrategy":"try-catch","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"}