500 Error message when I make a topic in a certain category (Infinite Flight Community)

AI-generated summary

SingaporeBanana reported a recurring 500 error when creating topics or moving them to the ‘Features’ category on the Infinite Flight Community. codinghorror requested reproduction of the issue. sam identified the root cause as a bug in an Active Record #includes query related to the hidden ‘order by likes’ feature, which caused query explosions. While a temporary fix involved reordering the category by likes, sam later confirmed a legitimate bug in the code’s monkey patch and deployed a permanent fix via a GitHub commit. Following this, techAPJ reverted their previous workaround on the specific category, configured it to sort by ‘Original Post Likes’, and verified that the 500 error was resolved.

I don’t know why I can’t make a topic in a certain category (Features) today as the “500 Error” message keeps showing up. I did make a topic and forgot to move it to features, when I moved this, The message keeps showing up

3 Likes

Can we repro this @techapj?

3 Likes

There is a nasty error in Active Record, where adding a #includes on a model can cause various queries to explode when we pluck ids.

op_likes ordering (order by number of likes on first post) was a pretty hidden feature only exposed via the default category order dialog.

We are pulling the feature altogether, @techAPJ will pull it and add a migration that remaps this to order by likes for categories that want to specify it as ordering.

In the meantime @techAPJ changed the offending category on infinite flight to order by likes by default.

7 Likes

Actually looks like this is a legit bug in our monkey patch, so I went ahead and fixed the monkey patch, per:

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

10 Likes

I reverted my change on community.infinite-flight.com/c/features just now to sort by Original Posts Lkes and can confirm that everything is good now. :thumbsup:

9 Likes