{"record":{"id":"43f86766118be87a","repo":"HKUDS/DeepTutor","slug":"avatar-must-be-a-png-jpeg-or-webp-image","errorCode":null,"errorMessage":"Avatar must be a PNG, JPEG or WebP image.","messagePattern":"Avatar must be a PNG, JPEG or WebP image\\.","errorType":"http","errorClass":"HTTPException","httpStatus":415,"severity":"error","filePath":"deeptutor/api/routers/auth.py","lineNumber":683,"sourceCode":"        )\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.\",\n        )\n\n    from deeptutor.multi_user.identity import save_avatar_file\n\n    # Bump the version embedded in the marker so clients cache-bust the URL.\n    previous = str(info.get(\"avatar\") or \"\")\n    version = 1\n    if previous.startswith(\"img:\"):\n        try:\n            version = int(previous.split(\":\", 1)[1]) + 1\n        except ValueError:\n            version = 1\n    marker = f\"img:{version}\"\n\n    save_avatar_file(current.user_id, data, ext)\n    if not set_avatar(current.username, marker):","sourceCodeStart":665,"sourceCodeEnd":701,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/auth.py#L665-L701","documentation":"Error \"Avatar must be a PNG, JPEG or WebP image.\" thrown in HKUDS/DeepTutor.","triggerScenarios":"Thrown at deeptutor/api/routers/auth.py:683 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"}