BerriAI/litellm · error · HTTPException

user_email '{member.user_email}' and user_id '{member.user_i

Error message

user_email '{member.user_email}' and user_id '{member.user_id}' do not belong to the same user.

What it means

Error "user_email '{member.user_email}' and user_id '{member.user_id}' do not belong to the same user." thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/management_endpoints/team_endpoints.py:2955

        if users_by_email is None or (isinstance(users_by_email, list) and len(users_by_email) == 0):
            # User doesn't exist yet - this is fine, will be created later
            return member

        if isinstance(users_by_email, list) and len(users_by_email) > 1:
            raise HTTPException(
                status_code=400,
                detail={
                    "error": f"Multiple users found with email '{member.user_email}'. Please use 'user_id' instead."
                },
            )

        # Get the single user
        user_by_email = users_by_email[0]

        # Verify the user_id matches
        if user_by_email.user_id != member.user_id:
            raise HTTPException(
                status_code=400,
                detail={
                    "error": f"user_email '{member.user_email}' and user_id '{member.user_id}' do not belong to the same user."
                },
            )

        # Both match, return as is
        return member

    # Case 2: Only user_email provided - populate user_id from DB
    if member.user_email is not None and member.user_id is None:
        user_by_email = await _user_db(prisma_client).find_first(
            where={"user_email": {"equals": member.user_email, "mode": "insensitive"}}
        )

        if user_by_email is None:
            # User doesn't exist yet - this is fine, will be created later
            return member

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Pass only the correct user_id or user_email; the two given identifiers refer to different users.

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/team_endpoints.py:2955 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/d495796bee90eaa7. Report an issue: GitHub.