HKUDS/DeepTutor · error · ValueError
Email cannot be empty
Error message
Email cannot be empty
What it means
Pydantic field_validator error on RegisterRequest.username raised when the submitted username/email is empty after stripping. First line of defense in the bootstrap-registration schema; pydantic turns it into a 422 with this detail.
Solutions
- Require a non-empty username/email in the registration form before submitting
- Trim client-side whitespace prior to the POST /register call
- Catch the 422 and show the field error inline
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at deeptutor/api/routers/auth.py:106 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/0ff46f07afc80610.
Report an issue: GitHub.
Appendix: source
Thrown at deeptutor/api/routers/auth.py:106
username: str
password: str
class RegisterRequest(BaseModel):
"""Payload for the POST /register endpoint."""
username: str
password: str
@field_validator("username")
@classmethod
def username_valid(cls, v: str) -> str:
import re
v = v.strip()
if not v:
raise ValueError("Email cannot be empty")
# Accept standard email addresses (used by PocketBase mode) or plain
# usernames (used by the built-in SQLite/JSON auth mode).
email_re = re.compile(r"^[^@\s]+@[^@\s]+\.[^@\s]+$")
plain_re = re.compile(r"^[A-Za-z0-9_\-.]{3,64}$")
if not email_re.match(v) and not plain_re.match(v):
raise ValueError("Enter a valid email address")
return v
@field_validator("password")
@classmethod
def password_valid(cls, v: str) -> str:
if len(v) < 8:
raise ValueError("Password must be at least 8 characters")
return v
class SetRoleRequest(BaseModel):
"""Payload for the PUT /users/{username}/role endpoint."""View on GitHub (pinned to 3e82f13042)