BerriAI/litellm · error · HTTPException

User already exists with username: {user.userName}

Error message

User already exists with username: {user.userName}

What it means

SCIM POST /Users: the provided userName is used as the LiteLLM user_id, and a lookup shows a user already exists with it. Creating a duplicate is refused with 409-style conflict semantics (HTTPException), pushing clients toward GET/PUT on the existing user.

Source

Thrown at litellm/proxy/management_endpoints/scim/scim_v2.py:1426

)
async def create_user(
    user: SCIMUser = Body(...),
):
    """
    Create a user according to SCIM v2 protocol
    """
    try:
        verbose_proxy_logger.debug("SCIM CREATE USER request: %s", user.model_dump())
        prisma_client: Final = await _get_prisma_client_or_raise_exception()

        # Extract data from SCIM user
        user_data: Final = _extract_scim_user_data(user)

        # Check if user already exists
        if user.userName:
            existing_user = await _table(UserRepository(prisma_client)).find_unique(where={"user_id": user.userName})
            if existing_user:
                raise HTTPException(
                    status_code=409,
                    detail={"error": f"User already exists with username: {user.userName}"},
                )

        # Create user in database
        user_id: Final = user.userName or str(uuid.uuid4())
        metadata: Final = _build_scim_metadata(
            user_data["given_name"],
            user_data["family_name"],
            enterprise=user_data["enterprise"],
            entitlements=user_data["entitlements"],
            roles=user_data["roles"],
        )

        default_role: Final = _default_scim_user_role()
        admin_group: Final = await _get_scim_admin_group()
        resolved_role: Final = _resolve_scim_user_role(user.groups or [], admin_group, default_role)

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use a different userName, or update the existing user via PATCH /Users/{id}.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/scim/scim_v2.py:1426 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/8a3a20d19e1a26c4. Report an issue: GitHub.