<forum>/search returns 500 error

AI-generated summary

The discussion addresses a 500 server error occurring when accessing the /search endpoint directly without query parameters. ErikV reported the issue on multiple forums, noting that while the search page fails with a 500 error, using the magnifying glass link (which includes a query) works correctly ErikV.

tobiaseigen confirmed the bug is legitimate, observing that direct visits to /search or /search?q= trigger the error, whereas searching with terms returns results. He suggested a more user-friendly approach would be to display a blank search form instead of an error. Mittineague and cpradio provided screenshots showing the error, with Mittineague noting the behavior varies between direct link clicks and manual URL entry, suggesting a potential browser-specific or relative link issue. tibarra initially suspected a Chrome-specific bug, but techAPJ confirmed they could reproduce the issue locally.

techAPJ quickly implemented a fix via a Discourse commit, which was related to a previous change. tibarra asked for clarification on the logic, and cpradio explained that the code attempts to find user data on a result object that is null when visiting /search directly. With the fix applied, techAPJ confirmed the search page now loads correctly.

On my forum and on this forum, if I go to http:// forum address /search I get a 500 error.

Any known workarounds?

Thanks!

إعجابَين (2)

Can you give the complete address?

https://meta.discourse.org/search

I’m not sure if this is a correct address for this application, is it? @zogstrip @codinghorror @sam

I’m not 100% sure it worked on this forum before, but it definitely worked on mine: http://talk.sparrowbrowser.com/search

This looks like a legit bug, though not high priority since few people will find themselves here.

If you search for e.g.

https://community.namati.org/search?q=community%20land%20protection

you get results.

But if you visit ..

https://community.namati.org/search

.. or even ..

https://community.namati.org/search?q=

.. you get an ugly error.

Would be more sensible to be shown a blank search form ready to be used to search for something.

إعجاب واحد (1)

Yeah, using the magnifying glass link works just fine. For us this is an issue because we liked the /search page a lot and are pointing people toward it.

Not what I’m getting using Firefox by a direct click on the link

But if I put the URL into the address bar I get a blank page.

A relative link thing?

Weird, I get a Server 500 error

me too. In Chrome, I get the server 500 error, here on meta and in our community.

Seems that the bug is in chrome, i got and error too.

Interesting to know that it’s browser-dependent!

I can repro this issue locally, working on a fix now.

5 إعجابات

Fixed via:

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

Was related to this commit.

cc @sam

6 إعجابات

Can you explain me how the ‘if result’ works in this case? I will appreciate it a lot.

It will only run find_user_data(guardian) on result, if result has a value. In this case, since you are visitng /search directly, there is no result

إعجابَين (2)

Oh i got it! Thanks for the explanation, cheers! I think this post should be closed right?

Yep, search page loads fine now: Search results for '' - Discourse Meta

4 إعجابات