# Issue with renaming user with unicode characters

**URL:** https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628
**Category:** Support
**Created:** [November 23, 2022, 9:29am UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628 "2022-11-23T09:29:24Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [November 23, 2022, 9:29am UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/1 "2022-11-23T09:29:24Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 23, 2022, 11:20am UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/2 "2022-11-23T11:20:11Z")

</div>

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`).

---

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [November 23, 2022, 3:57pm UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/3 "2022-11-23T15:57:42Z")

</div>

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

Found this:

```plaintext
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.

---

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [November 24, 2022, 9:36am UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/4 "2022-11-24T09:36:31Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 24, 2022, 11:08am UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/5 "2022-11-24T11:08:07Z")

</div>

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

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [November 24, 2022, 11:33am UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/6 "2022-11-24T11:33:58Z")

</div>

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](https://meta.discourse.org/t/142537?silent=true)?
- 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?

```plaintext
./launcher enter app
rails c

```

```ruby
user = User.find_by_username("moep")
new_username = "Möp"
UsernameChanger.change(user, new_username, Discourse.system_user)

```

---

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [November 24, 2022, 11:49am UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/7 "2022-11-24T11:49:25Z")

</div>

> [@gerhard](#):
>
> What version of Discourse are you using?

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

> [@gerhard](#):
>
> Is this a [standard install](https://meta.discourse.org/t/142537?silent=true)?

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.

> [@gerhard](#):
>
> Is there some kind of reverse proxy in front of your Discourse?

Apache 2.4

> [@gerhard](#):
>
> Which browser are you using?

Chrome, Brave.

> [@gerhard](#):
>
> What’s the value of the `allowed_unicode_username_characters` setting?

`[äöüßÄÖÜẞ]`

> [@gerhard](#):
>
> Does renaming in the rails console work

It does not work either:

```plaintext
=> "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:

```plaintext
env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8
  DISCOURSE_DEFAULT_LOCALE: de

```

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

```plaintext
env:
  LANG: en_US.UTF-8
  DISCOURSE_DEFAULT_LOCALE: de

```

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?

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [November 24, 2022, 11:57am UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/8 "2022-11-24T11:57:18Z")

</div>

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.

> [@Roi](#):
>
> What else is handled by `discourse-migratepassword` that it needs to be active after the import from phpBB?

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

---

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [November 24, 2022, 12:03pm UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/9 "2022-11-24T12:03:24Z")

</div>

> [@gerhard](#):
>
> 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! 🙂

---

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [November 24, 2022, 7:17pm UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/10 "2022-11-24T19:17:47Z")

</div>

> [@gerhard](#):
>
> It isn’t useful _during_ the import, only _after_ the import as it allows your users to login with their old password.

Disabling and then renaming the users worked. Thank you again. 🙂

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 24, 2022, 7:41pm UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/11 "2022-11-24T19:41:25Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [November 25, 2022, 12:39pm UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/12 "2022-11-25T12:39:44Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [November 25, 2022, 1:21pm UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/13 "2022-11-25T13:21:05Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [December 25, 2022, 1:21pm UTC](https://meta.discourse.org/t/issue-with-renaming-user-with-unicode-characters/246628/14 "2022-12-25T13:21:05Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
