BerriAI/litellm · error · ValueError

User does not exist in LiteLLM_UserTable. user_id={member.us

Error message

User does not exist in LiteLLM_UserTable. user_id={member.user_id} and user_email={member.user_email}

What it means

Raised inside add_member when both user_id and user_email lookups fail and no new user could be created: the referenced member simply does not exist in LiteLLM_UserTable. It surfaces as a ValueError that the caller converts into an HTTP error; at-fault input is an unknown member identifier.

Source

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

            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,
                detail={"error": "Multiple users with this email found in db. Please use 'user_id' instead."},
            )
        elif existing_user_email_row is not None:
            user_object = LiteLLM_UserTable.model_validate(existing_user_email_row.model_dump())
        elif existing_user_id_row is not None:
            user_object = LiteLLM_UserTable.model_validate(existing_user_id_row.model_dump())
        else:
            raise HTTPException(
                status_code=404,
                detail={"error": f"User not found for user_id={member.user_id} and user_email={member.user_email}"},
            )

        if user_object is None:
            raise ValueError(
                f"User does not exist in LiteLLM_UserTable. user_id={member.user_id} and user_email={member.user_email}"
            )

        # Add user to organization
        _organization_membership: Final = await _table(OrganizationMembershipRepository(prisma_client)).create(
            data={
                "organization_id": organization_id,
                "user_id": user_object.user_id,
                "user_role": member.role,
            }
        )
        organization_membership: Final = LiteLLM_OrganizationMembershipTable.model_validate(
            _organization_membership.model_dump()
        )
        return user_object, organization_membership

    except Exception as e:
        raise ValueError(f"Error adding member={member} to organization={organization_id}: {e}")

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Create the user first via /user/new, then add them to the organization.
Defensive patterns

Strategy: validation

When it happens

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