500 error when approving a reviewable post after editing tags in /review (tags saved as objects, not strings)

AI-generated summary

A bug report details a 500 Internal Server Error occurring when a moderator attempts to approve a post in the /review queue after editing its tags. The issue stems from the reviewable payload storing full tag objects instead of tag name strings after editing, causing a type mismatch during the approval process TheBaby5. A workaround was suggested to normalize the tags back to strings before saving. nat acknowledged the report and confirmed that the issue will be resolved in pull request discourse/discourse#37477 nat.

Summary

In the review queue (/review), if a moderator edits the tags on a queued post and then clicks Approve, the approval request fails with a 500 Internal Server Error.


Steps to Reproduce

  1. Ensure a post is waiting in the review queue (e.g., from a user/group that requires approval).
  2. Go to /review.
  3. Open the queued item.
  4. Edit tags using the tag selector UI.
  5. Click Approve.
  6. Observe a 500 response.

Expected Behavior

The post should be approved successfully, with the updated tags applied.


Actual Behavior

Approval fails with a 500 error.

Example request pattern:

PUT /review/{id}/perform/approve_post?version={x} → 500 (Internal Server Error)

What Seems To Be Happening (Root Cause)

After editing tags in the review UI, the reviewable payload stores full tag objects instead of tag name strings.

Before editing tags:

payload["tags"] = ["tag-one", "tag-two"]

After editing tags in /review:

payload["tags"] = [
  {"id"=>123, "name"=>"tag-one", "description"=>nil, "count"=>50, ...},
  {"id"=>456, "name"=>"tag-two", "description"=>nil, "count"=>30, ...}
]

When the approve action processes tags, it appears to expect strings, but receives hashes/objects, leading to the 500.


Workaround

Normalize tags back to names:

r = ReviewableQueuedPost.find(ID)
r.payload["tags"] = r.payload["tags"].map { |t| t.is_a?(Hash) ? t["name"] : t }
r.save!

1 Like

Thanks for reporting. We’ll have a look.

3 Likes

This will be fixed in FIX: Cater for reviewable tag payloads that have been saved as names by nattsw · Pull Request #37477 · discourse/discourse · GitHub. Highly appreciate the quick bug report.

4 Likes

This topic was automatically closed after 2 days. New replies are no longer allowed.