HKUDS/DeepTutor · error · ValueError
Unsupported avatar extension: {ext!r}
Error message
Unsupported avatar extension: {ext!r} What it means
Error "Unsupported avatar extension: {ext!r}" thrown in HKUDS/DeepTutor.
Source
Thrown at deeptutor/multi_user/identity.py:317
def _avatar_dir() -> Path:
# Resolved lazily so tests that monkeypatch AUTH_DIR keep avatars isolated.
return AUTH_DIR / "avatars"
def get_avatar_file(user_id: str) -> Path | None:
"""Return the stored avatar image for ``user_id``, or None."""
for ext in AVATAR_EXTENSIONS:
candidate = _avatar_dir() / f"{user_id}.{ext}"
if candidate.is_file():
return candidate
return None
def save_avatar_file(user_id: str, data: bytes, ext: str) -> Path:
"""Atomically persist an avatar image, replacing any previous one."""
if ext not in AVATAR_EXTENSIONS:
raise ValueError(f"Unsupported avatar extension: {ext!r}")
directory = _avatar_dir()
directory.mkdir(parents=True, exist_ok=True)
target = directory / f"{user_id}.{ext}"
tmp = directory / f"{user_id}.{ext}.tmp"
tmp.write_bytes(data)
tmp.replace(target)
# A re-upload may change the extension; drop stale siblings.
for other in AVATAR_EXTENSIONS:
if other != ext:
(directory / f"{user_id}.{other}").unlink(missing_ok=True)
return target
def delete_avatar_file(user_id: str) -> None:
for ext in AVATAR_EXTENSIONS:
(_avatar_dir() / f"{user_id}.{ext}").unlink(missing_ok=True)
View on GitHub (pinned to 3e82f13042)
When it happens
Trigger: Thrown at deeptutor/multi_user/identity.py:317 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/c3eefe028ef1d0c8.
Report an issue: GitHub.