BerriAI/litellm · error · HTTPException

Only proxy admins may set user_id to a different user.

Error message

Only proxy admins may set user_id to a different user.

What it means

HTTPException(403) from the memory row-identity resolver: a non-admin caller set user_id in the request body to a user other than themselves. Non-admins can only create memory entries stamped with their own identity; admins may override for shared rows.

Source

Thrown at litellm/proxy/memory/memory_endpoints.py:281

) -> tuple[str | None, str | None]:
    """
    Resolve the (user_id, team_id) to stamp on a new row.

    - PROXY_ADMIN: may override either dimension via the request body.
    - Everyone else: the requested values must match their own (or be omitted).

    Also rejects identity-less creation: a row with both user_id and team_id
    NULL is invisible to every non-admin caller (the visibility filter would
    never match it), so we refuse to create orphan rows unless the caller is
    a PROXY_ADMIN who is explicitly stamping a global/shared row.
    """
    if _is_admin(user_api_key_dict):
        user_id = requested_user_id if requested_user_id is not None else user_api_key_dict.user_id
        team_id = requested_team_id if requested_team_id is not None else user_api_key_dict.team_id
        return user_id, team_id

    if requested_user_id is not None and requested_user_id != user_api_key_dict.user_id:
        raise HTTPException(
            status_code=403,
            detail="Only proxy admins may set user_id to a different user.",
        )
    if requested_team_id is not None and requested_team_id != user_api_key_dict.team_id:
        raise HTTPException(
            status_code=403,
            detail="Only proxy admins may set team_id to a different team.",
        )
    user_id = user_api_key_dict.user_id
    team_id = user_api_key_dict.team_id
    if not user_id and not team_id:
        # Orphan row: no user_id and no team_id means no non-admin can ever
        # see it again via the visibility filter. Reject up front.
        raise HTTPException(
            status_code=400,
            detail=(
                "Cannot create a memory entry without a user_id or team_id. "
                "Authenticate with a key that has a user_id or team_id, or call "

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Omit user_id or set it to your own user, or call as a proxy admin.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/memory/memory_endpoints.py:281 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/0f6a2ae39a5dc8a3. Report an issue: GitHub.