fromConfig will call ClientBuilder->setConnectionParams() after ClientBuilder->setBasicAuthentication() and the basic authentication will be overridden, therefore the performed requests will result to status code 401.
The same behavior would also happen when someone calls $clientBuilder->setBasicAuthentication() before $clientBuilder->setConnectionParams().
What is the expected behavior?
The order of the $client properties should be in depended. ClientBuilder->setConnectionParams() needs to merge the given params with $this->connectionParams instead of overriding it.
What is the bug?
Creating the Client with
ClientBuilder::fromConfig
may overrides basic authentication depending on the order of the given$config
array.How can one reproduce the bug?
fromConfig
will callClientBuilder->setConnectionParams()
afterClientBuilder->setBasicAuthentication()
and the basic authentication will be overridden, therefore the performed requests will result to status code 401. The same behavior would also happen when someone calls$clientBuilder->setBasicAuthentication()
before$clientBuilder->setConnectionParams()
.What is the expected behavior?
The order of the
$client
properties should be in depended.ClientBuilder->setConnectionParams()
needs to merge the given params with$this->connectionParams
instead of overriding it.What is your host/environment?
Do you have any screenshots?
Do you have any additional context?
opensearch-project/opensearch-php
Version 2.2.0I am ready to create a PR for this issue.