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

[BUG] PHP warning Undefined array key "root_cause" in Connection::tryDeserializeError() #167

Closed
drunken-monkey opened this issue Nov 18, 2023 · 0 comments · Fixed by #168
Labels
bug Something isn't working

Comments

@drunken-monkey
Copy link
Contributor

What is the bug?

The code for “2.0 structured exceptions” is faulty in \OpenSearch\Connections\Connection::tryDeserializeError(). It will produce a warning (Undefined array key "root_cause") if $error['error']['root_cause'] is not set.

This happens, e.g., when the OpenSearch server returns a 403 error status. In this case, the error key of the response contains just the keys reason and type.

How can one reproduce the bug?

  1. Configure your OpenSearch server to require authentification
  2. Specify wrong auth details when creating the client object in PHP
  3. Upon sending a request (which the server rejects with 403), you will see the PHP warning Undefined array key "root_cause".

What is the expected behavior?

Erorr responses without root_cause should be handled without producing a PHP warning.

What is your host/environment?

  • Arch Linux 6.6.1
  • PHP 8.1.12
  • OpenSearch 2.9.0
  • Latest dev version of this library
@drunken-monkey drunken-monkey added bug Something isn't working untriaged labels Nov 18, 2023
@drunken-monkey drunken-monkey changed the title [BUG] [BUG] PHP warning Undefined array key "root_cause" in Connection::tryDeserializeError() Nov 18, 2023
@dblock dblock removed the untriaged label Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants