Skip to content

Php Exception inside Transport.php when document not found #1058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
szambonurek opened this issue Aug 21, 2020 · 2 comments
Closed

Php Exception inside Transport.php when document not found #1058

szambonurek opened this issue Aug 21, 2020 · 2 comments
Labels

Comments

@szambonurek
Copy link

Summary of problem or feature request

When document with specified id is not found there is an php exception inside Transport.php

vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php:127

Cannot use object of type Elasticsearch\Common\Exceptions\Missing404Exception as array

vendor/react/promise/src/RejectedPromise.php:28

$this->reason = 
Elasticsearch\Common\Exceptions\Missing404Exception Object
(
    [message:protected] => {"_index":"myindex","_type":"_doc","_id":"1","found":false}
    [string:Exception:private] => 
    [code:protected] => 404
    [file:protected] => /home/myuser/www/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php
    [line:protected] => 633
    [trace:Exception:private] => Array
 *RECURSION*
    [previous:Exception:private] => 
)

This is the problem, you use object as array:
vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php:127
if (!(isset($response['code']) && $response['code'] >=400 && $response['code'] < 500)) {

Code snippet of problem

$client is \Elasticsearch\Client
$client->get([1, 'myindex'])

System details

PHP 7.4.9
Ubuntu 20.04
Elastic 7.8.0
elasticsearch/elasticsearch v7.9.0
ezimuel/ringphp 1.1.2
ezimuel/guzzlestreams 3.0.1
react/promise v2.8.0

@ezimuel
Copy link
Contributor

ezimuel commented Sep 30, 2020

@szambonurek thanks for reporting the issue. It was a strange one since it does not appear at runtime. I fixed with PR #1066 including also a unit test.

@ezimuel
Copy link
Contributor

ezimuel commented Oct 1, 2020

Solved in #1066

@ezimuel ezimuel closed this as completed Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants