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?
Configure your OpenSearch server to require authentification
Specify wrong auth details when creating the client object in PHP
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 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 keysreason
andtype
.How can one reproduce the bug?
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?