Not a bug Server error if Elasticsearch is not running

AndyB

Well-known member
Affected version
Enhanced search v2.2.2
If Elasticsearch is not running and you try to do a search the following server error is displayed:

1638552489400.png

If Elasticsearch is not running, it would be better to return this error phrase:

return $this->error(\XF::phrase('xfes_elasticsearch_server_could_not_be_reached'));
 
Last edited:
I believe XF only displays exceptions if DEBUG is enabled in your config.php. Otherwise it gives a less technical error.

Also. Normal users have no idea what ElasticSearch is and don’t care. All they need to know is that the page is temporarily unavailable.
 
The error shows on the front end to any logged in member but only if debug mode is enabled.
I was observing different behavior: the trace was showing even with debug mode disabled.

Looking at \XF\ControllerPlugin\Error::actionException, it seems the logic is to display the error if the site is in debug mode or the current visitor is an admin. Otherwise, a generic error with no trace will be displayed.
 
I just checked and indeed if I'm logged in a normal registered user and Elasticsearch is not running, I get a proper message like this:

1643753020219.webp
 
I don't think we'll be making any changes here. There are a number of places which make calls that will throw if a connection to Elasticsearch cannot be established, and indeed the exception is only displayed to administrators or while in debug mode. This shouldn't occur under normal circumstances anyway.
 
Top Bottom