BerriAI/litellm · error · ValueError

Potential NON-Existent or Duplicate user email in DB: Error

Error message

Potential NON-Existent or Duplicate user email in DB: Error finding a unique instance of user_email={member.user_email} in LiteLLM_UserTable.: {e}

What it means

When a member is supplied only by user_email, the unique lookup on LiteLLM_UserTable throws (email absent or duplicated). add_member converts that Prisma failure into a ValueError telling the caller the email is non-existent or not unique. The at-fault input is member.user_email that cannot be resolved to exactly one row.

Source

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

    """

    try:
        user_object: LiteLLM_UserTable | None = None
        existing_user_id_row = None
        existing_user_email_row = None
        ## Check if user exists in LiteLLM_UserTable - user exists - either the user_id or user_email is in LiteLLM_UserTable
        if member.user_id is not None:
            existing_user_id_row = await _table(UserRepository(prisma_client)).find_unique(
                where={"user_id": member.user_id}
            )

        if existing_user_id_row is None and member.user_email is not None:
            try:
                existing_user_email_row = await UserRepository(prisma_client).table.find_unique(
                    where={"user_email": member.user_email}
                )
            except Exception as e:
                raise ValueError(
                    f"Potential NON-Existent or Duplicate user email in DB: Error finding a unique instance of user_email={member.user_email} in LiteLLM_UserTable.: {e}"
                )

        ## If user does not exist, create a new user
        if existing_user_id_row is None and existing_user_email_row is None:
            # Create a new user - since user does not exist
            user_id: Final[str] = member.user_id or str(uuid.uuid4())
            new_user_defaults: Final = get_new_internal_user_defaults(
                user_id=user_id,
                user_email=member.user_email,
            )

            _returned_user = await prisma_client.insert_data(data=new_user_defaults, table_name="user")
            if _returned_user is not None:
                user_object = LiteLLM_UserTable.model_validate(_returned_user.model_dump())
        elif existing_user_email_row is not None and len(existing_user_email_row) > 1:
            raise HTTPException(
                status_code=400,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use user_id instead of user_email; the email is duplicated or non-existent.
  2. Check proxy logs for the underlying lookup error.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/organization_endpoints.py:1524 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/e17951886d1fa356. Report an issue: GitHub.