{"record":{"id":"c2339d28a3dfdc5f","repo":"HKUDS/DeepTutor","slug":"cannot-store-an-avatar-for-this-account","errorCode":null,"errorMessage":"Cannot store an avatar for this account.","messagePattern":"Cannot store an avatar for this account\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"deeptutor/api/routers/auth.py","lineNumber":667,"sourceCode":"@router.put(\"/profile/avatar\")\nasync def upload_avatar(\n    file: UploadFile = File(...),\n    payload: TokenPayload | None = Depends(require_auth),\n) -> dict:\n    \"\"\"Upload an avatar image for the current user.\n\n    The client is expected to crop/resize before uploading; the server only\n    enforces a size cap and validates the format by magic bytes. Not available\n    in PocketBase mode (those identities have no local user record).\n    \"\"\"\n    current = _require_profile_identity(payload)\n    if POCKETBASE_ENABLED:\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=\"Avatar upload is not available in PocketBase mode.\",\n        )\n    if not current.user_id or not _USER_ID_RE.match(current.user_id):\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=\"Cannot store an avatar for this account.\",\n        )\n    info = get_user_info(current.username)\n    if info is None:\n        raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=\"User not found\")\n\n    data = await file.read(_AVATAR_MAX_BYTES + 1)\n    if len(data) > _AVATAR_MAX_BYTES:\n        raise HTTPException(\n            status_code=status.HTTP_413_REQUEST_ENTITY_TOO_LARGE,\n            detail=\"Avatar image is too large (max 1 MB).\",\n        )\n    ext = _sniff_image(data)\n    if ext is None:\n        raise HTTPException(\n            status_code=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE,\n            detail=\"Avatar must be a PNG, JPEG or WebP image.\",","sourceCodeStart":649,"sourceCodeEnd":685,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/auth.py#L649-L685","documentation":"Error \"Cannot store an avatar for this account.\" thrown in HKUDS/DeepTutor.","triggerScenarios":"Thrown at deeptutor/api/routers/auth.py:667 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}