AlistGo/alist · warning · EmptyUsername
username is empty
Error message
username is empty
What it means
EmptyUsername is a sentinel in internal/errs/user.go raised during user validation when a request that requires a username supplies an empty one. It guards user creation/update in the admin API and the login flow before any credential check happens.
Source
Thrown at internal/errs/user.go:6
package errs
import "errors"
var (
EmptyUsername = errors.New("username is empty")
EmptyPassword = errors.New("password is empty")
WrongPassword = errors.New("password is incorrect")
DeleteAdminOrGuest = errors.New("cannot delete admin or guest")
)
View on GitHub (pinned to 843d9dc814)
Solutions
- Ensure the username field is non-empty before submitting (client-side required check)
- Inspect the actual JSON body sent — the key must be exactly 'username'
- Trim input and reject empty strings before calling the user API
- If scripting, validate generated usernames are populated before the request
Example fix
// before
if username == "" { /* nothing, request fails server-side */ }
// after
if strings.TrimSpace(username) == "" {
return errs.EmptyUsername
} Defensive patterns
Strategy: validation
Validate before calling
// client-side guard before login/user APIs
if strings.TrimSpace(username) == "" {
return errs.EmptyUsername
} Type guard
func hasUsername(s string) bool { return strings.TrimSpace(s) != "" } Try / catch
if err := login(user, pass); err != nil {
if errors.Is(err, errs.EmptyUsername) { /* prompt for username */ }
} Prevention
- Make the username field required in forms
- Validate generated usernames in scripts are non-empty
- Send the exact JSON key 'username'
- Trim and reject whitespace-only input client-side
When it happens
Trigger: POSTing a login request with an empty/missing username field; creating or updating a user via the admin API without a username; whitespace-only username that survives trimming checks.
Common situations: Forms with a missing username input; API scripts sending {"username":""} or omitting the key; automation generating users from unpopulated template variables; proxied requests where the field is dropped by a misconfigured body limit or middleware.
Related errors
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/6e1d282334d02b7d.
Report an issue: GitHub.