mattermost-community/focalboard · error
Unable to create the new user
Error message
Unable to create the new user
What it means
This error is returned by RegisterUser when the underlying store's CreateUser call fails while persisting a newly registered user. It is a wrapped error (github.com/pkg/errors.Wrap), so the original database/storage error (duplicate key, connection failure, constraint violation) is preserved as the cause. The wrapper itself just indicates that user creation at the persistence layer did not succeed.
Source
Thrown at server/app/auth.go:191
MinimumLength: 6,
}
err := auth.IsPasswordValid(password, passwordSettings)
if err != nil {
return errors.Wrap(err, "Invalid password")
}
_, err = a.store.CreateUser(&model.User{
ID: utils.NewID(utils.IDTypeUser),
Username: username,
Email: email,
Password: auth.HashPassword(password),
MfaSecret: "",
AuthService: a.config.AuthMode,
AuthData: "",
})
if err != nil {
return errors.Wrap(err, "Unable to create the new user")
}
return nil
}
func (a *App) UpdateUserPassword(username, password string) error {
err := a.store.UpdateUserPassword(username, auth.HashPassword(password))
if err != nil {
return err
}
return nil
}
func (a *App) ChangePassword(userID, oldPassword, newPassword string) error {
var user *model.User
if userID != "" {
var err errorView on GitHub (pinned to a84bbb65e3)
Solutions
- Inspect the wrapped cause (use %+v when logging) to see the actual store/database error and fix it first
- Verify the database is running and reachable and that connection settings (DSN, single-user vs full DB mode) are correct
- Check for an existing user with the same username or email before retrying, or handle the 'username already exists' race
- Run pending schema migrations / confirm the storage backend is writable and has free disk space
Example fix
// before: opaque handling
err := app.RegisterUser(username, email, password)
if err != nil {
return err
}
// after: log the full cause chain to identify the store error
err := app.RegisterUser(username, email, password)
if err != nil {
log.Printf("registration failed: %+v", err) // shows wrapped store error
if model.IsErrDuplicate(err) {
return errors.New("username or email already taken")
}
return errors.Wrap(err, "registration failed")
} Defensive patterns
Strategy: try-catch
Validate before calling
// Go: pre-validate inputs before calling RegisterUser
if len(username) == 0 || len(password) < 6 {
return errors.New("username required and password must be at least 6 characters")
}
if _, err := store.GetUserByUsername(username); err == nil {
return errors.New("username already exists")
}
if err := db.Ping(); err != nil {
return errors.Wrap(err, "database unreachable before registration")
} Try / catch
err := app.RegisterUser(username, email, password)
if err != nil {
log.Printf("register failed: %+v", err) // unwrap cause chain
if model.IsErrDuplicate(err) || strings.Contains(err.Error(), "already exists") {
// recoverable: prompt user for a different username
} else {
// infrastructure problem: report and back off
}
} Prevention
- Always log wrapped errors with %+v so the underlying store error is visible
- Check username/email availability in the UI before submitting registration
- Monitor database health and run migrations as part of deployment
- Enforce password policy (min length 6) client-side before calling the API
When it happens
Trigger: Calling RegisterUser (or the register API endpoint) when a.store.CreateUser returns an error: the database is unreachable, the users table/collection is missing, a unique index on username/email/ID is violated, or the store write is rejected for any other reason. Note that pre-checks for existing username/email happen earlier, so this fires mostly on races or store-level failures.
Common situations: Database not started or misconfigured (bad connection string) in self-hosted deployments; a race where two registrations with the same username land between the existence check and the insert; schema migrations not applied so the users table lacks required columns; read-only database credentials; single-store backends (SQLite file locked or disk full).
Related errors
- unable to update password
- card limit value is invalid
- database type is unsupported
- cannot notify block subscribers for block %s: %w
- cannot upsert notification hint: %w
AI-assisted analysis of mattermost-community/focalboard@a84bbb65e3 (2026-08-30).
Data as JSON: /api/errors/c609d8477252bf6a.
Report an issue: GitHub.