diff --git a/src/OpenSearch/Connections/Connection.php b/src/OpenSearch/Connections/Connection.php index cf25f7379..b24bcae4a 100644 --- a/src/OpenSearch/Connections/Connection.php +++ b/src/OpenSearch/Connections/Connection.php @@ -748,7 +748,7 @@ private function tryDeserializeError(array $response, string $errorClass): OpenS // 2.0 structured exceptions if (is_array($error['error']) && array_key_exists('reason', $error['error']) === true) { // Try to use root cause first (only grabs the first root cause) - $root = $error['error']['root_cause']; + $root = array_key_exists('root_cause',$error['error']) ? $error['error']['root_cause']:''; if (isset($root) && isset($root[0])) { $cause = $root[0]['reason']; $type = $root[0]['type'];