HKUDS/DeepTutor · error · HTTPException
You cannot delete your own account
Error message
You cannot delete your own account
What it means
HTTP 400 raised by the DELETE /users/{username} (remove_user) handler in deeptutor/api/routers/auth.py:829 when an admin attempts to delete their own account. Self-deletion is blocked to prevent the last active admin from removing themselves; only other users' accounts may be deleted.
Solutions
- Have another admin delete the account if truly needed
- Disable the delete action for the current user's row in the admin UI
- No retry will succeed until the caller is a different admin
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at deeptutor/api/routers/auth.py:829 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/b4b19adf056f32c4.
Report an issue: GitHub.
Appendix: source
Thrown at deeptutor/api/routers/auth.py:829
f"(role={role!r})"
)
return {
"ok": True,
"user_id": user_id,
"username": body.username,
"role": role,
"is_admin": role == "admin",
}
@router.delete("/users/{username}", status_code=status.HTTP_200_OK)
async def remove_user(
username: str,
current: TokenPayload = Depends(require_admin),
) -> dict:
"""Delete a user. Admins cannot delete their own account."""
if current and username == current.username:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="You cannot delete your own account",
)
# Capture the id before the record disappears so the avatar file can go too.
info = get_user_info(username)
removed = delete_user(username)
if not removed:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="User not found")
user_id = str(info.get("id") or "") if info else ""
if user_id and _USER_ID_RE.match(user_id):
from deeptutor.multi_user.identity import delete_avatar_file
delete_avatar_file(user_id)
logger.info(f"Admin '{current.username if current else 'local'}' deleted user '{username}'")View on GitHub (pinned to 3e82f13042)