{"record":{"id":"c609d8477252bf6a","repo":"mattermost-community/focalboard","slug":"unable-to-create-the-new-user","errorCode":null,"errorMessage":"Unable to create the new user","messagePattern":"Unable to create the new user","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/app/auth.go","lineNumber":191,"sourceCode":"\t\tMinimumLength: 6,\n\t}\n\n\terr := auth.IsPasswordValid(password, passwordSettings)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Invalid password\")\n\t}\n\n\t_, err = a.store.CreateUser(&model.User{\n\t\tID:          utils.NewID(utils.IDTypeUser),\n\t\tUsername:    username,\n\t\tEmail:       email,\n\t\tPassword:    auth.HashPassword(password),\n\t\tMfaSecret:   \"\",\n\t\tAuthService: a.config.AuthMode,\n\t\tAuthData:    \"\",\n\t})\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Unable to create the new user\")\n\t}\n\n\treturn nil\n}\n\nfunc (a *App) UpdateUserPassword(username, password string) error {\n\terr := a.store.UpdateUserPassword(username, auth.HashPassword(password))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc (a *App) ChangePassword(userID, oldPassword, newPassword string) error {\n\tvar user *model.User\n\tif userID != \"\" {\n\t\tvar err error","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/mattermost-community/focalboard/blob/a84bbb65e32edf972856b329417096ac413518e9/server/app/auth.go#L173-L209","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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"],"exampleFix":"// before: opaque handling\nerr := app.RegisterUser(username, email, password)\nif err != nil {\n    return err\n}\n\n// after: log the full cause chain to identify the store error\nerr := app.RegisterUser(username, email, password)\nif err != nil {\n    log.Printf(\"registration failed: %+v\", err) // shows wrapped store error\n    if model.IsErrDuplicate(err) {\n        return errors.New(\"username or email already taken\")\n    }\n    return errors.Wrap(err, \"registration failed\")\n}","handlingStrategy":"try-catch","validationCode":"// Go: pre-validate inputs before calling RegisterUser\nif len(username) == 0 || len(password) < 6 {\n    return errors.New(\"username required and password must be at least 6 characters\")\n}\nif _, err := store.GetUserByUsername(username); err == nil {\n    return errors.New(\"username already exists\")\n}\nif err := db.Ping(); err != nil {\n    return errors.Wrap(err, \"database unreachable before registration\")\n}","typeGuard":null,"tryCatchPattern":"err := app.RegisterUser(username, email, password)\nif err != nil {\n    log.Printf(\"register failed: %+v\", err) // unwrap cause chain\n    if model.IsErrDuplicate(err) || strings.Contains(err.Error(), \"already exists\") {\n        // recoverable: prompt user for a different username\n    } else {\n        // infrastructure problem: report and back off\n    }\n}","preventionTips":["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"],"tags":["go","auth","user-registration","database"],"backgroundTag":"user-creation-failed","analyzedSha":"a84bbb65e32edf972856b329417096ac413518e9","analyzedAt":"2026-08-30T09:22:20.720Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}