Problem/Motivation
Many functions in src/SearchAPI/BackendClient catch exceptions but not all that can be thrown by what they are calling.
For example, in indexExists, $this->client->indices()->exists() can also throw Psr\Http\Client\ClientExceptionInterface based on OpenSearch\TransportInterface::sendRequest
It looks like many of the other methods could have similar treatment
Steps to reproduce
Try to import config changes to a SAPI OS index when the OS instance is down/unreachable
Get an error Unexpected error during import with operation update for search_api.index.global_search: cURL error 6: Could not resolve host: opensearch
Proposed resolution
Also catch ClientExceptionInterface
Issue fork search_api_opensearch-3530261
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
acbramley commentedComment #4
kim.pepperThanks for reporting. We actually need to remove
\OpenSearch\Common\Exceptions\OpenSearchExceptionas it is deprecated inopensearch-project/opensearch-php2.4.0Comment #5
acbramley commentedYeah I thought about doing that here but wasn't entirely sure what it should be replaced with, maybe just the interface?
Comment #6
kim.pepperWe should be able to just catch
OpenSearchExceptionInterfaceas we convert any HTTP responses with status >= 400 to an instance of\OpenSearch\Exception\HttpExceptionInterfacewhich extends\OpenSearch\Exception\OpenSearchExceptionInterface.Comment #7
acbramley commentedThat doesn't work for the original issue in the IS (it's still GuzzleHttp\Exception\ConnectException)
Comment #8
kim.pepperHmm. What version of
opensearch-phpare you using?Ah you are right, because we don't catch \Psr\Http\Client\ClientExceptionInterface anywhere.
Comment #9
kim.pepperUpdated to catch both OpenSearchExceptionInterface and ClientExceptionInterface
Comment #10
acbramley commentedCool! Just need to fix phpcs (again) :)
Comment #13
kim.pepperCommitted to 3.x and 2.x. Thanks!