Skip to content
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

Declaration of Elastic\Elasticsearch\Response\Elasticsearch::withStatus(int $code, string $reasonPhrase = ''): Psr\Http\Message\ResponseInterface must be compatible with PsrExt\Http\Message\ResponseInterface::withStatus($code, $reasonPhrase = <default>) #1327

Closed
ccc-nghia-le opened this issue Jun 29, 2023 · 6 comments

Comments

@ccc-nghia-le
Copy link

ccc-nghia-le commented Jun 29, 2023

Summary of problem or feature request

I created a deployment in elasticloud, and set up the connection. Then I performed a search using $client->search() surrounded it with a try catch code block,
via debugging I could it failed with http code 401 Unauthorised, I believe there is something wrong with my elasticloud setup, that's fine. I expected it would hit my catch() block but it never did. Instead there was an error thrown:

Declaration of Elastic\Elasticsearch\Response\Elasticsearch::withStatus(int $code, string $reasonPhrase = ''): Psr\Http\Message\ResponseInterface must be compatible with PsrExt\Http\Message\ResponseInterface::withStatus($code, $reasonPhrase = <default>)

Code snippet of problem

$client = Elastic\Elasticsearch\ClientBuilder::create()
->setElasticCloudId('')
->setApiKey('')
->build();

try {
$result = $client->search($params);
} catch (\Exception $e) {
dd(' It should hit here but it did not');
}

System details

  • Operating System: Ubuntu
  • PHP Version: 8.1
  • ES-PHP client version: 8.8.1
  • Elasticsearch version: 8.8.1
@danielsimkus
Copy link

I got this too.
Had to do composer require elasticsearch/elasticsearch:8.8.0 to get it working, something about allowing psr/http-message: ^2 is causing issues from 8.8.1

@ccc-nghia-le
Copy link
Author

ccc-nghia-le commented Jul 7, 2023

I got this too. Had to do composer require elasticsearch/elasticsearch:8.8.0 to get it working, something about allowing psr/http-message: ^2 is causing issues from 8.8.1

Downgrading to 8.8.0 did actually help. Thank you very much !

I hope they will fix this soon in a future release.

@ezimuel ezimuel closed this as completed Jul 17, 2023
@murilolivorato
Copy link

thanks a lot, its worked for me as well .

@ezimuel
Copy link
Contributor

ezimuel commented Aug 2, 2023

@murilolivorato, @ccc-nghia-le and @danielsimkus can you try the PR #1344 and let me know if this fix the issue? Thanks!

@ezimuel ezimuel reopened this Aug 2, 2023
@ezimuel
Copy link
Contributor

ezimuel commented Aug 3, 2023

I finally reproduced the issue, read here: #1342 (comment)

@ezimuel
Copy link
Contributor

ezimuel commented Aug 14, 2023

The discussion will continue in #1342. If you still have issue please test this solution.

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

No branches or pull requests

4 participants