SOLVED: Unable to Grant Admin or Grant Moderator to existing users

I’m having difficulty granting Admin or Moderator rights to existing users.

Everything else is Discourse is working 100% fine, but I don’t seem to be able to save the changes after clicking on the ‘Grant Admin’ or ‘Grant Moderator’ button on the user management page. The buttons do change their legend to ‘Revoke Admin’ or ‘Revoke Moderator’ respectively, but following a page refresh they have reverted to their previous ‘Grant’ legend.

I tried granting admin privileges to an existing user using the command line, by following the instructions at Create Admin Account from Console, but this failed with the following stack trace:

root@dhi-discourse-app:~# rake admin:create
Email:  xxxxxxxxxxx@gmail.com
User with this email already exists! Do you want to reset the password for this email? (Y/n)  n

Ensuring account is active!

Account updated successfully!
Do you want to grant Admin privileges to this account? (Y/n)  y
rake aborted!
ActiveRecord::RecordInvalid: Validation failed: Name must be at least 6 characters
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/validations.rb:57:in `save!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/transactions.rb:273:in `block in save!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/database_statements.rb:199:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/transactions.rb:208:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/transactions.rb:273:in `save!'
/var/www/discourse/app/models/group.rb:138:in `refresh_automatic_group!'
/var/www/discourse/app/models/group.rb:151:in `block in refresh_automatic_groups!'
/var/www/discourse/app/models/group.rb:150:in `each'
/var/www/discourse/app/models/group.rb:150:in `refresh_automatic_groups!'
/var/www/discourse/app/models/concerns/roleable.rb:38:in `block in save_and_refresh_staff_groups!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/transactions.rb:208:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/transactions.rb:259:in `transaction'
/var/www/discourse/app/models/concerns/roleable.rb:36:in `save_and_refresh_staff_groups!'
/var/www/discourse/app/models/concerns/roleable.rb:44:in `set_permission'
/var/www/discourse/app/models/concerns/roleable.rb:28:in `grant_admin!'
/var/www/discourse/lib/tasks/admin.rake:83:in `block in <top (required)>'
Tasks: TOP => admin:create
(See full trace by running task with --trace)
root@dhi-discourse-app:~#

I’m guessing that whatever is stopping the rake task from working has got something to do with the failure of setting Admin or Moderator via the GUI as well?

I’ve also tested this using the rake admin:create task to create a new user AND make them admin - it still fails with the same error.

my setup is vanilla: discourse-docker on Ubuntu 14 server on digital ocean 2 core, 2 gb, 40gb ssd

Any thoughts?

M

Did you change minimum name length for users in the site settings?

This can cause bad things to happen if you have existing users with names that are “too short” based on your new setting.

Thanks @codinghorror I had edited that setting for no particularly good reason early on when I set up the instance. I have reset it to the default and the problem is fixed.
Thanks again. And thanks for the speed of reply too.
M