elasticsearch icon indicating copy to clipboard operation
elasticsearch copied to clipboard

Error reporting is broken

Open arnaud-lb opened this issue 3 years ago • 0 comments

The HTTP transport will always return ["error" => "", "code" => 0] in case of network error. This makes debugging difficult.

At line 207 below, we check if $response is false, but it's always a string. In case of network error, it will be the empty string, json_decode() fails, and ["error" => "", "code" => 0] is returned.

https://github.com/nervetattoo/elasticsearch/blob/d033461b1baf8eaa5f5c18bd0fb21927e02ce03c/src/ElasticSearch/Transport/HTTP.php#L205-L213

Using curl_geterrno() === 0 instead of $response !== false fixes the problem.

arnaud-lb avatar Jul 09 '20 09:07 arnaud-lb