Continuing the discussion from
How to anonymise a single post?:
I tried this just now, and the anonymous user created for the user was 20-character set of seemingly random alphanumeric characters beginning with cb426… I had expected it to be in the format “anonymous99” or “anonymous100”.
Is this a bug or am I doing something the wrong way?
I have just impersonated a test user and then entered anonymous mode and the name generated is in the
Is this something you can replicate on more than one account?
Yes, it’s the same (albeit a different random username) for another user I tried it with.
I’m using 2.9.0.beta10 (0c38757250).
I wonder whether I have anonymous mode enabled for TL1+ and was trying to impersonate/anonymise a TL0 user. I’ll check later.
I made sure that
allow anonymous posting was set, that
anonymous posting min trust level was 0, created a brand new user, logged in as that user (not impersonating), entered anonymous mode, and the username created was…
So it’s something about anonymising on its own, rather than just when impersonating. I’ll change the title of this topic from
Anonymous user created when impersonating user doesn’t begin with “anonymous” to something more accurate.
P.S. still 2.9.0.beta10 (
Do you have a lot of anonymous users?
We have really weird issue, up until user 100 the username was in this format
e.g. anonymous10, anonymous55, anonymous100
However as soon as we reached over number 100 anonymous user accounts, they are now in this format:
I think this was fixed at the time, but there may have been a regression?
Just over a dozen, plus four of these 20-random-character users in the last fortnight or so.
The person it cropped up for had created a real username “Anonymous20” when the next anonymised name would have been “anonymous20” (I can’t remember the actual number).
(I then renamed him and added “anonymous” to the list of words you can’t use in a username.)
Could that be relevant?
This sounds promising. Let me check on my test site.
Cheers. Looking at it, to
reserved usernames I added
I’ve just removed those two additions, and it all works fine again! Thanks for pointing me to the old topic which made me think of this.
It would still be good to prevent users from creating accounts with the word “anonymous” in it, but still have anonymous mode work properly. I guess this is still a bug.
anonymous* that’s the culprit:
user_name_suggester checks the reserved names before allocating one, so adding that will be what’s gumming it up:
# frozen_string_literal: true
RSpec.describe UserNameSuggester do
describe '.suggest' do
SiteSetting.min_username_length = 3
SiteSetting.max_username_length = 15
SiteSetting.reserved_usernames = ''
it "keeps adding numbers to the username" do
Fabricate(:user, username: 'sam')
Fabricate(:user, username: 'sAm1')
Fabricate(:user, username: 'sam2')
Fabricate(:user, username: 'sam4')
Thanks for clarifying this.
Maybe it would be better for Discourse to check
reserved usernames but ignore any prohibition on the word “anonymous” when creating an anonymous user.