Searching yields "500 Internal Server Error" for specific search phrases

Hi there,

we are observing sporadic problems using the search feature of Discourse.


During the last weeks, we observed sporadic “500 Internal Server Error” responses when searching on While that might sound funny, we believe it actually depends on the search phrase.

The problem only happens when using the ad hoc search near the hamburger menu. When navigating to the search page /search before and invoking the search from there, everything is fine.

Now, after others also pointed us towards that problem on our platform, we finally wanted to start investigating this problem in detail.

See for yourself

Lucky us, we just have been able to reproduce it on Meta. So, when searching for “search returns 500”, we have been able to trigger that error deterministically. It also happens when not being logged in to the system.


The response is:


The search phrase is the bad guy – seriously?

It feels like that. Searching for “search croaks 500” in the same manner does not trigger that problem.


We find this thing both weird and funny enough that we wanted to share our observations with you. While we are not exactly suffering badly, I believe you would like to investigate this if your time permits.

Thanks for listening and with kind regards,

P.S.: Triggering that error while searching for the issue on Meta makes it even more funny as I believe we all still love recursions.


Hmm, yes. This is the error we get in the logs

URI::InvalidURIError (bad URI(is not URI?): "http:error]")
/usr/local/lib/ruby/2.6.0/uri/rfc3986_parser.rb:67:in `split'

/usr/local/lib/ruby/2.6.0/uri/rfc3986_parser.rb:67:in `split'
/usr/local/lib/ruby/2.6.0/uri/rfc3986_parser.rb:73:in `parse'
/usr/local/lib/ruby/2.6.0/uri/common.rb:234:in `parse'
/usr/local/lib/ruby/2.6.0/uri/common.rb:737:in `URI'
/var/www/discourse/lib/search/grouped_search_results.rb:83:in `block in blurb_for'
/usr/local/lib/ruby/2.6.0/set.rb:338:in `each_key'
/usr/local/lib/ruby/2.6.0/set.rb:338:in `each'
/var/www/discourse/lib/search/grouped_search_results.rb:82:in `blurb_for'
/var/www/discourse/lib/search/grouped_search_results.rb:60:in `blurb'
/var/www/discourse/app/serializers/search_post_serializer.rb:9:in `blurb'

Thanks for the report @amotl


Thanks @amotl and @david, this is now fixed here on meta via FIX: skip invalid URLs when checking for audio/video in search blurbs · discourse/discourse@0dfc594 · GitHub


Dear @david and @pmusaraj,

thanks for the quick turnaround time on this, from confirmation to the actual fix. We are looking forward to receive this fix. Will it be included within 2.4.0.beta7 maybe?

With kind regards,


Yes, it will be included in the next beta.


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