{"record":{"id":"ca6bce4354529ef4","repo":"BerriAI/litellm","slug":"member-not-found-in-organization-for-user-id-data","errorCode":null,"errorMessage":"Member not found in organization for user_id={data.user_id}","messagePattern":"Member not found in organization for user_id=(.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"litellm/proxy/management_endpoints/organization_endpoints.py","lineNumber":1363,"sourceCode":"            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,\n            LitellmUserRoles.PROXY_ADMIN_VIEW_ONLY.value,\n        ):\n            if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN.value:\n                raise HTTPException(\n                    status_code=403,\n                    detail={\n                        \"error\": (","sourceCodeStart":1345,"sourceCodeEnd":1381,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/organization_endpoints.py#L1345-L1381","documentation":"The membership query succeeded but returned None: the user exists but has no membership row in this organization. This fires on member update/delete flows when the caller targets a user who was never added to (or was already removed from) the given organization; raised as 404.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/organization_endpoints.py:1363 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the user_id is a member of the organization before updating."],"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"}