Issue with renaming user with unicode characters

I am having problems renaming a user back to the old username (I imported from phpBB and had to rename some users, e.g. Möp to Moep). I get a 500 error when I try to rename the user, also when reloading the user has still the name without the umlaut. Any idea? The unicode settings are enabled, the umlauts are allowed and also external system avatars enabled is enabled.

You’ll need to look at the logs and see what’s there. You might see in /logs or you might need to look at /var/discourse/shared/standalone/log/rails/production.log (I think it’s log and not logs).


Ah thank you. I had no idea if and where there are logfiles. Now I know. :slight_smile:

Found this:

Started PUT "/users/moep/preferences/username" for xxxx:c5:9f0d:4c00:xxxx:e179:xxxx:xxxx at 2022-11-23 15:53:52 +0000
Processing by UsersController#username as */*
  Parameters: {"new_username"=>"Möp", "username"=>"moep"}
Completed 500 Internal Server Error in 338ms (ActiveRecord: 0.0ms | Allocations: 137204)
Encoding::CompatibilityError (incompatible character encodings: ASCII-8BIT and UTF-8)
app/models/user.rb:1806:in `username_validator'
app/services/username_changer.rb:35:in `change'
app/services/username_changer.rb:13:in `change'
app/controllers/users_controller.rb:202:in `username'

There is more, but I thought it might be enough. If now, I can provide more.

Btw, I tried more than one username and had similar problems.

1 Like

@pfaffman can you see the cause in my logs why I get the 500 error? :slight_smile:

It didn’t like the characters in the username. I don’t know why.

I just tested renaming a user from “moep” to “Möp” and it worked.

  • What version of Discourse are you using?
  • Is this a standard install?
  • Is there some kind of reverse proxy in front of your Discourse?
  • Which browser are you using?
  • What’s the value of the allowed_unicode_username_characters setting?
  • Does renaming in the rails console work?
    ./launcher enter app
    rails c
    user = User.find_by_username("moep")
    new_username = "Möp"
    UsernameChanger.change(user, new_username, Discourse.system_user)
1 Like

Latest. Which should be 2.9.0.beta12 at the moment.

Yes. Just renamed the container name as I plan to run more than one discourse instance. But at the moment it is only one running.

Apache 2.4

Chrome, Brave.


It does not work either:

=> "Wägi"
[6] pry(main)> UsernameChanger.change(user, new_username, Discourse.system_user)
Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8
from /var/www/discourse/plugins/discourse-migratepassword/plugin.rb:78:in `+'

Here I tried “Waegi” to “Wägi”.

What I noticed: I use a new template version for the container which holds the following information:

  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8

In the old template (2019 or so) there only was:

  LANG: en_US.UTF-8

Does this maybe have to do with the problem? And are these the right settings for a Discourse installation with main language German?

Oh and I noticed now that the error is thrown by discourse-migratepassword - which was the reason why I renamed the users before importing everything from phpBB to Discourse.

Would it be useful to disable discourse-migratepassword, rename the users and then enable it again? What else is handled by discourse-migratepassword that it needs to be active after the import from phpBB?


It looks like the discourse-migratepassword plugin isn’t compatible with Unicode usernames.
cc @michaeld

Yes, disabling the plugin should fix this issue for you.

It isn’t useful during the import, only after the import as it allows your users to login with their old password.


Okay thank you. So I would disable it, rename the users and then enable it again right away. Thanks again! :slight_smile:

1 Like

Disabling and then renaming the users worked. Thank you again. :slight_smile:

I was wondering: Can the users with umlauts now logon with their old phhBB password as discourse-migratepassword seems to have this unicode problem?

1 Like

I’m pretty sure that the first time they log in their password is saved as a Discourse password, so you don’t need it anymore. It sounds like anyone who is going to log in with the imported password has already.

1 Like

I am not able to reproduce this issue. Same settings for unicode ans allowed characters, I even made a user with the same username and renamed it to Möp. There should be something else - that I am not aware of - for this issue to surface?

1 Like

Strange. I had this issue with every username I tried. as unicode characters I only had German umlauts like äöü. Another example was: Waegi back to Wägi.

This issue first came up in the phpBB3 import to Discourse script, which was the reason for me to rename all umlaut users in phpBB and then restart the import script. For sure I wanted the users in Discourse again with their original username.