Body is too similar to what you previously posted - even when previous post didn't go through

There are times when you try to post in a topic, only to get some kind of server error (usually just with a generic “internal server error” message). The problem is, when you try again, you get that “body is too similar” error message instead, and you can’t post without changing the body of your message. Considering that the original message didn’t go through, I don’t think you should get the “body is too similar” error.

3 Likes

This is legit:

https://github.com/discourse/discourse/blob/a19170a4c2c37bb6f6ae9531fe4f925777f3e8d5/lib/post_creator.rb#L170-L170

We store the key in redis a bit too early which means that a whole slew of errors can mean we never roll back the redis key.

Additionally, looking at post creator there are conditions where it can raise and then this line never hits:

https://github.com/discourse/discourse/blob/a19170a4c2c37bb6f6ae9531fe4f925777f3e8d5/lib/post_creator.rb#L185-L185

So rolling back this redis set is a bit tricky cause we need to do it for 2 types of conditions (general error OR errors are not blank and the error is not the too similar one)

Additionally this does raise the point on review that #create can technically raise an exception which is a bit inconsistent.

@tgxworld can you add cleaning this up to your list?

5 Likes

I don’t think we need to handle the rolling back of the Redis key at all. We just have to set the redis key outside of the transaction when the post has been saved successfully.

3 Likes

The issue described in this topic is fixed in

https://github.com/discourse/discourse/commit/ec27db78bec4b50a475a5dd830bc0d695bfe66cd

@seanblue If possible, can you provide me with the backtrace of the log when you encounter the “internal server error”?

9 Likes

I’m not sure I understand the question. What do you mean by “backtrace of the log”?