BerriAI/litellm · error · HTTPException

User id does not exist in 'LiteLLM_UserTable'. Fix this by c

Error message

User id does not exist in 'LiteLLM_UserTable'. Fix this by creating user via `/user/new`.

What it means

HTTPException raised when creating an invitation link fails because the referenced user_id has no row in LiteLLM_UserTable (Prisma foreign-key violation on the invitation insert). The invited user must be created first via /user/new before an invitation can be issued.

Source

Thrown at litellm/proxy/management_helpers/user_invitation.py:43

    current_time: Final = litellm.utils.get_utc_datetime()
    expires_at: Final = current_time + timedelta(days=7)

    try:
        response: Final = await InvitationLinkRepository(prisma_client).table.create(
            data={
                "user_id": data.user_id,
                "created_at": current_time,
                "expires_at": expires_at,
                "created_by": user_api_key_dict.user_id or litellm_proxy_admin_name,
                "updated_at": current_time,
                "updated_by": user_api_key_dict.user_id or litellm_proxy_admin_name,
            }
        )
        return response
    except Exception as e:
        if "Foreign key constraint failed on the field" in str(e):
            raise HTTPException(
                status_code=400,
                detail={
                    "error": "User id does not exist in 'LiteLLM_UserTable'. Fix this by creating user via `/user/new`."
                },
            )
        raise HTTPException(status_code=500, detail={"error": str(e)})

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Create the user first via POST /user/new, then retry the invitation.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/management_helpers/user_invitation.py:43 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/9ef1694b5e60d144. Report an issue: GitHub.