mattermost-community/focalboard · error

unable to update password

Error message

unable to update password

What it means

This error is wrapped around the store's UpdateUserPasswordByID failure inside ChangePassword. It means the user was authenticated (userID resolved and old password matched) but persisting the new hashed password to storage failed. The original store error is preserved as the cause via errors.Wrap.

Source

Thrown at server/app/auth.go:227

		var err error
		user, err = a.store.GetUserByID(userID)
		if err != nil {
			return errors.Wrap(err, "invalid username or password")
		}
	}

	if user == nil {
		return errors.New("invalid username or password")
	}

	if !auth.ComparePassword(user.Password, oldPassword) {
		a.logger.Debug("Invalid password for user", mlog.String("userID", user.ID))
		return errors.New("invalid username or password")
	}

	err := a.store.UpdateUserPasswordByID(userID, auth.HashPassword(newPassword))
	if err != nil {
		return errors.Wrap(err, "unable to update password")
	}

	return nil
}

View on GitHub (pinned to a84bbb65e3)

Solutions

  1. Log the error with %+v to reveal the wrapped store error and address the underlying database problem
  2. Verify database connectivity and that the storage backend is writable
  3. Retry the change once the database is healthy; confirm the user row still exists
  4. Check schema migrations are up to date for the users table

Example fix

// before: swallowing detail
if err := app.ChangePassword(userID, old, new); err != nil {
    http.Error(w, "something went wrong", 500)
}

// after: surface the cause chain for diagnosis
if err := app.ChangePassword(userID, old, new); err != nil {
    log.Printf("password update failed: %+v", err)
    http.Error(w, "could not update password, check database health", 500)
}
Defensive patterns

Strategy: retry

Validate before calling

// Go: confirm DB writability before the password change
if err := db.Ping(); err != nil {
    return errors.Wrap(err, "database unreachable")
}
if _, err := store.GetUserByID(userID); err != nil {
    return errors.Wrap(err, "user must exist before password update")
}

Try / catch

err := app.ChangePassword(userID, oldPassword, newPassword)
for attempt := 0; err != nil && attempt < 2; attempt++ {
    time.Sleep(time.Duration(1<<attempt) * 100 * time.Millisecond)
    err = app.ChangePassword(userID, oldPassword, newPassword)
}
if err != nil {
    log.Printf("password update failed after retries: %+v", err)
}

Prevention

When it happens

Trigger: Calling ChangePassword with valid credentials when a.store.UpdateUserPasswordByID returns an error: database unreachable, users table missing or schema mismatch, write rejected (read-only credentials, disk full), or the user row was deleted concurrently between the lookup and the update.

Common situations: Database outage or connection pool exhaustion during a password change; migration drift so the password column differs from the model; concurrent user deletion racing the update; SQLite file lock contention in single-user deployments.

Related errors


AI-assisted analysis of mattermost-community/focalboard@a84bbb65e3 (2026-08-30). Data as JSON: /api/errors/01602e7793cfb13e. Report an issue: GitHub.