# Setting 'min username length' greater than 5 breaks granting and revoking Admin/Moderator permissions

**URL:** <https://meta.discourse.org/t/setting-min-username-length-greater-than-5-breaks-granting-and-revoking-admin-moderator-permissions/57079>\
**Category:** Bug\
**Created:** [7 Febrero, 2017 16:50 UTC](https://meta.discourse.org/t/setting-min-username-length-greater-than-5-breaks-granting-and-revoking-admin-moderator-permissions/57079 "2017-02-07T16:50:10Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![MarkT](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markt/32/64156_2.png) [@MarkT](https://meta.discourse.org/u/MarkT)\
**Post date:** [7 Febrero, 2017 16:50 UTC](https://meta.discourse.org/t/setting-min-username-length-greater-than-5-breaks-granting-and-revoking-admin-moderator-permissions/57079/1 "2017-02-07T16:50:10Z")

</div>

We ran into an issue while setting up our Discourse forum. We were trying to grant Moderator permission to an account we created for our Sales team, but kept receiving a `422 error`.

I went through our error logs and this was showing up:

```
ActiveRecord::RecordInvalid (Validation failed: Name must be at least 6 characters)
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/validations.rb:79:in `raise_record_invalid'

```

We had modified the _min username length_ to **6** instead of the default **3** when first going through the setup since that is the length we want to require. Once I reset the field to **3** I was able to add/remove the Moderator permissions. I did some testing and found that I could change _min username length_ anywhere from **1-5** and it did not cause an issue, but as soon as it was set to **6** or greater it broke granting or removing Admin/Moderator permissions.

This didn’t make sense to me since we only had 6 Users and all of their usernames were **6** characters or more. I looked through the rest of our forum to see if there was anything that would be related specifically to Moderators/Admins and had a name that was less than 6 characters. The _staff_ Group is the only thing that I’ve been able to find that meets those criteria. And since it is **5** characters that may be the reason that I can set _min username length_ up to **5** and not cause any issues. This definitely seems like something is not connected correctly within the system.

I found a couple of Topics here with similar issues:

[https://meta.discourse.org/t/unable-to-grant-admin-because-username-must-be-at-least-6-characters/25271](https://meta.discourse.org/t/unable-to-grant-admin-because-username-must-be-at-least-6-characters/25271)

> [@Can't revoke moderator status](https://meta.discourse.org/t/cant-revoke-moderator-status/51799):
>
> I need to change up my admins/moderators. But I am getting an error when I hit “revoke moderator” Any ideas? Thanks Alex

The _‘solution’_ to both of those issues was to just reset _min username length_ to the default value, which is just a workaround not an actual fix for the issue.

Other than this issue the rest of the setup has been a breeze. Thanks for the great product.

---

_[View the full topic](https://meta.discourse.org/t/setting-min-username-length-greater-than-5-breaks-granting-and-revoking-admin-moderator-permissions/57079)._
