# Ruby hash syntax being displayed in emails sent to deleted users

**URL:** https://meta.discourse.org/t/ruby-hash-syntax-being-displayed-in-emails-sent-to-deleted-users/382411
**Category:** Bug
**Tags:** email, review-queue, fixed
**Created:** [September 12, 2025, 7:39am UTC](https://meta.discourse.org/t/ruby-hash-syntax-being-displayed-in-emails-sent-to-deleted-users/382411 "2025-09-12T07:39:51Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [September 12, 2025, 7:39am UTC](https://meta.discourse.org/t/ruby-hash-syntax-being-displayed-in-emails-sent-to-deleted-users/382411/1 "2025-09-12T07:39:51Z")

</div>

When a user is deleted by rejecting their first post, they are sent an email with the subject line of `Your account has been deleted`.

There is a bug in the body / content of the email, it appears to be displaying some kind of Ruby hash syntax in the middle section of the email:

> [@](#):
>
> Hello,
> 
> This is an automated message from SITE NAME to let you know that the user account associated with this email address has been deleted by a staff member.
> 
> {:off\_topic=\>“Your post was flagged as **off-topic** : the community feels it is not a good fit for the topic, as currently defined by the title and the first post.”, :inappropriate=\>“Your post was flagged as **inappropriate** : the community feels it is offensive, abusive, to be hateful conduct or a violation of our [community guidelines](https://meta.discourse.org/guidelines).”, :illegal=\>“Your post was flagged as **illegal** : the community thinks it might be breaking the law.”, :spam=\>“Your post was flagged as **spam** : the community feels it is an advertisement, something that is overly promotional in nature instead of being useful or relevant to the topic as expected.”, :notify\_moderators=\>“Your post was flagged **for moderator attention** : the community feels something about the post requires manual intervention by a staff member.”, :responder=\>{:off\_topic=\>“The post was flagged as **off-topic** : the community feels it is not a good fit for the topic, as currently defined by the title and the first post.”, :inappropriate=\>“The post was flagged as **inappropriate** : the community feels it is offensive, abusive, to be hateful conduct or a violation of our [community guidelines](https://meta.discourse.org/guidelines).”, :spam=\>“The post was flagged as **spam** : the community feels it is an advertisement, something that is overly promotional in nature instead of being useful or relevant to the topic as expected.”, :notify\_moderators=\>“The post was flagged **for moderator attention** : the community feels something about the post requires manual intervention by a staff member.”}}
> 
> Please review our community guidelines for details.

* * *

Here’s a screen shot of the email the user receives, showing the formatting:

 ![Screenshot 2025-09-12 at 08.41.38](https://global.discourse-cdn.com/meta/original/4X/4/e/a/4ea38c88154f66721b084d2b52dc8b0e64d038d8.png)

* * *

Steps to replicate:

1. Ensure Discourse requires the first post of every user to be approved
2. Create a new user
3. Create a new post with the new user
4. Using an admin account, reject the post with the “Delete user” option
5. New user is sent an email with the above content

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [September 12, 2025, 7:41am UTC](https://meta.discourse.org/t/ruby-hash-syntax-being-displayed-in-emails-sent-to-deleted-users/382411/2 "2025-09-12T07:41:14Z")

</div>

If it helps, a couple of screen shots from the admin view of the rejected post:

Before deleting the user:

 ![Screenshot 2025-09-12 at 08.30.49](https://global.discourse-cdn.com/meta/original/4X/5/1/7/517a1491ff2a2ac82fa44dec804c390fe95af046.png)

After rejection and deletion:

 ![Screenshot 2025-09-12 at 08.30.59](https://global.discourse-cdn.com/meta/original/4X/d/8/f/d8fe56becae86a217393704a9d41096ab49e15f5.png)

---

<div class="post-metadata">

### Author: ![selase](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/selase/32/270909_2.png) [@selase](https://meta.discourse.org/u/selase)
#### Post date: [November 18, 2025, 11:45am UTC](https://meta.discourse.org/t/ruby-hash-syntax-being-displayed-in-emails-sent-to-deleted-users/382411/3 "2025-11-18T11:45:31Z")

</div>

A post was split to a new topic: [Fix deleted user email handling for staged users](https://meta.discourse.org/t/fix-deleted-user-email-handling-for-staged-users/388806)

---

<div class="post-metadata">

### Author: ![selase](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/selase/32/270909_2.png) [@selase](https://meta.discourse.org/u/selase)
#### Post date: [September 12, 2025, 6:24pm UTC](https://meta.discourse.org/t/ruby-hash-syntax-being-displayed-in-emails-sent-to-deleted-users/382411/4 "2025-09-12T18:24:44Z")

</div>

This looks like a bug in how `flag_reason` is generated here:

> <https://github.com/discourse/discourse/blob/1aa055cee202d3045594eaf6f14b3742b0e71d34/app/mailers/user_notifications.rb#L181-L190>

`PostActionTypeView.new.types` doesn’t include `:needs_approval` flag (which gets created in the flow described). Because of this, the translation key resolves to `flag_reasons.` (with no suffix), which returns the entire YAML section instead of a single entry. That’s why there is a Ruby hash in place of the flag reason.

> <https://github.com/discourse/discourse/blob/1aa055cee202d3045594eaf6f14b3742b0e71d34/config/locales/server.en.yml#L3365-L3375>

Relatedly, this likely impacts custom flags as well, since their translations would also be missing.

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [September 12, 2025, 6:43pm UTC](https://meta.discourse.org/t/ruby-hash-syntax-being-displayed-in-emails-sent-to-deleted-users/382411/6 "2025-09-12T18:43:38Z")

</div>

> [@selase](#):
>
> this likely impacts custom flags as well

I am sure it does. I mentioned that in May

> [@User deleted email is sent even when deletion failed](https://meta.discourse.org/t/user-deleted-email-is-sent-even-when-deletion-failed/368240/1):
>
> ![image](https://global.discourse-cdn.com/meta/original/4X/1/d/b/1db1706585dced9324701fbc4525229ae64bc7ad.png)

> [@User deleted email is sent even when deletion failed](https://meta.discourse.org/t/user-deleted-email-is-sent-even-when-deletion-failed/368240/1):
>
> ### Side note:
> 
> - [As mentioned before](https://meta.discourse.org/t/modify-add-site-text-associated-with-custom-moderation-flags/335942/5), `flag reasons` does not work with custom flags

---

<div class="post-metadata">

### Author: ![selase](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/selase/32/270909_2.png) [@selase](https://meta.discourse.org/u/selase)
#### Post date: [November 18, 2025, 11:51am UTC](https://meta.discourse.org/t/ruby-hash-syntax-being-displayed-in-emails-sent-to-deleted-users/382411/7 "2025-11-18T11:51:59Z")

</div>

We’ve merged a fix for the issue in the OP. I’ve moved the report related to staged users into its own [topic](https://meta.discourse.org/t/fix-deleted-user-email-handling-for-staged-users/388806) to make it easier to track pending a fix.

[https://github.com/discourse/discourse/pull/34955](https://github.com/discourse/discourse/pull/34955)

---

<div class="post-metadata">

### Author: ![selase](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/selase/32/270909_2.png) [@selase](https://meta.discourse.org/u/selase)
#### Post date: [November 18, 2025, 11:52am UTC](https://meta.discourse.org/t/ruby-hash-syntax-being-displayed-in-emails-sent-to-deleted-users/382411/8 "2025-11-18T11:52:06Z")

</div>


