BerriAI/litellm · error · HTTPException

Error finding organization membership for user_id={data.user

Error message

Error finding organization membership for user_id={data.user_id} in organization={data.organization_id}: {e}

What it means

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.

Source

Thrown at litellm/proxy/management_endpoints/organization_endpoints.py:1356

        # Check if member exists in organization
        if data.user_email is not None and data.user_id is None:
            existing_user_email_row: Final = await find_member_if_email(data.user_email, prisma_client)
            data.user_id = existing_user_email_row.user_id

        try:
            existing_organization_membership: Final = await _table(
                OrganizationMembershipRepository(prisma_client)
            ).find_unique(
                where={
                    "user_id_organization_id": {
                        "user_id": data.user_id,
                        "organization_id": data.organization_id,
                    }
                }
            )
        except Exception as e:
            raise HTTPException(
                status_code=400,
                detail={
                    "error": f"Error finding organization membership for user_id={data.user_id} in organization={data.organization_id}: {e}"
                },
            )
        if existing_organization_membership is None:
            raise HTTPException(
                status_code=404,
                detail={"error": f"Member not found in organization for user_id={data.user_id}"},
            )

        # Reject attempts to change the role of a global PROXY_ADMIN via
        # org-scoped operations. An org-admin of any org could otherwise
        # alter a PROXY_ADMIN user's per-org role, which has downstream
        # effects on admin UI filtering and scope derivation.
        target_user_row = await _table(UserRepository(prisma_client)).find_unique(where={"user_id": data.user_id})
        if target_user_row is not None and getattr(target_user_row, "user_role", None) in (
            LitellmUserRoles.PROXY_ADMIN.value,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Verify the user_id is a member of the organization.
  2. Check proxy server logs for the underlying exception.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/organization_endpoints.py:1356 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/69178e53d6b64038. Report an issue: GitHub.