Ruby hash syntax being displayed in emails sent to deleted users

AI-generated summary

A bug in Discourse causes Ruby hash syntax to appear in the email sent to users when their accounts are deleted after rejecting their first post. The issue stems from a missing translation key for the :needs_approval flag in the flag_reasons hash, leading to improper rendering of the email content. Richie reported the issue with screenshots, and selase identified the root cause in the code. The bug also affects custom flags, as noted by Moin. A fix has been merged, and a related issue for staged users has been moved to a separate topic. selase confirmed the resolution.

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:


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


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
2 Likes

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

Before deleting the user:

After rejection and deletion:

1 Like

A post was split to a new topic: Fix deleted user email handling for staged users

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

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.

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

7 Likes

I am sure it does. I mentioned that in May

3 Likes

We’ve merged a fix for the issue in the OP. I’ve moved the report related to staged users into its own topic to make it easier to track pending a fix.

https://github.com/discourse/discourse/pull/34955

1 Like