HKUDS/DeepTutor · error · HTTPException

Avatar upload is not available in PocketBase mode.

Error message

Avatar upload is not available in PocketBase mode.

What it means

HTTP 400 raised by PUT /profile/avatar in PocketBase mode. PocketBase identities have no local user record, so there is nowhere to store an uploaded avatar file; the feature is intentionally unavailable.

Solutions

  1. Use PocketBase's own user-avatar management for those identities
  2. Hide the avatar-upload control when the client detects PocketBase mode
  3. Use icon markers (icon:<name>:<color>) instead where supported
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at deeptutor/api/routers/auth.py:662 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/fabc175b4696d23b. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/api/routers/auth.py:662

    if current.user_id and _USER_ID_RE.match(current.user_id):
        delete_avatar_file(current.user_id)
    return {"ok": True, "avatar": body.avatar}


@router.put("/profile/avatar")
async def upload_avatar(
    file: UploadFile = File(...),
    payload: TokenPayload | None = Depends(require_auth),
) -> dict:
    """Upload an avatar image for the current user.

    The client is expected to crop/resize before uploading; the server only
    enforces a size cap and validates the format by magic bytes. Not available
    in PocketBase mode (those identities have no local user record).
    """
    current = _require_profile_identity(payload)
    if POCKETBASE_ENABLED:
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail="Avatar upload is not available in PocketBase mode.",
        )
    if not current.user_id or not _USER_ID_RE.match(current.user_id):
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail="Cannot store an avatar for this account.",
        )
    info = get_user_info(current.username)
    if info is None:
        raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="User not found")

    data = await file.read(_AVATAR_MAX_BYTES + 1)
    if len(data) > _AVATAR_MAX_BYTES:
        raise HTTPException(
            status_code=status.HTTP_413_REQUEST_ENTITY_TOO_LARGE,
            detail="Avatar image is too large (max 1 MB).",
        )

View on GitHub (pinned to 3e82f13042)