Significant-Gravitas/AutoGPT · warning · HTTPException

User {user_id} not found

Error message

User {user_id} not found

What it means

HTTP 404 from the admin get-tier endpoint: get_user_email_by_id(user_id) returned None, which the route treats as proof the user does not exist in the database. No tier lookup is attempted.

Source

Thrown at autogpt_platform/backend/backend/api/features/admin/rate_limit_admin_routes.py:194

@router.get(
    "/rate_limit/tier",
    response_model=UserTierResponse,
    summary="Get User Rate Limit Tier",
)
async def get_user_rate_limit_tier(
    user_id: str,
    admin_user_id: str = Security(get_user_id),
) -> UserTierResponse:
    """Get a user's current rate-limit tier. Admin-only.

    Returns 404 if the user does not exist in the database.
    """
    logger.info("Admin %s checking tier for user %s", admin_user_id, user_id)

    resolved_email = await get_user_email_by_id(user_id)
    if resolved_email is None:
        raise HTTPException(status_code=404, detail=f"User {user_id} not found")

    tier = await get_user_tier(user_id)
    return UserTierResponse(user_id=user_id, tier=tier)


@router.post(
    "/rate_limit/tier",
    response_model=UserTierResponse,
    summary="Set User Rate Limit Tier",
)
async def set_user_rate_limit_tier(
    request: SetUserTierRequest,
    admin_user_id: str = Security(get_user_id),
) -> UserTierResponse:
    """Set a user's rate-limit tier. Admin-only.

    Returns 404 if the user does not exist in the database.
    """

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Verify the user_id exists as a User row in the target database
  2. Copy the full UUID without truncation (watch log-prefixed 12-char forms)
  3. Confirm environment alignment between the admin tool and the database it queries
  4. If the user was deleted, no tier exists — remove or recreate the account as appropriate
Defensive patterns

Strategy: validation

Validate before calling

from uuid import UUID
uid = UUID(user_id)  # malformed ids fail locally
# optionally verify existence: user = await get_user_by_id(uid); assert user

Type guard

def is_uuid(v: str) -> TypeGuard[str]:
    try:
        UUID(v); return True
    except (ValueError, TypeError):
        return False

Try / catch

if resp.status_code == 404:
    # no User row — confirm environment/database before reporting 'no such user'

Prevention

When it happens

Trigger: GET the user rate-limit tier route with a user_id that has no User row: malformed or foreign UUID, user deleted, or pointing at a different environment's database than where the user lives.

Common situations: Copy-pasting a user id from a staging ticket into a prod admin tool (or vice versa); users deleted between id capture and the tier check; UUIDs with a missing or extra segment after manual transcription; Supabase auth user created but User row not yet synced.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/80b22f8220e6ab6d. Report an issue: GitHub.