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

Command icon 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

acbramley created an issue. See original summary.

acbramley’s picture

Status: Active » Needs review
kim.pepper’s picture

Thanks for reporting. We actually need to remove \OpenSearch\Common\Exceptions\OpenSearchException as it is deprecated in opensearch-project/opensearch-php 2.4.0

acbramley’s picture

Yeah I thought about doing that here but wasn't entirely sure what it should be replaced with, maybe just the interface?

kim.pepper’s picture

We should be able to just catch OpenSearchExceptionInterface as we convert any HTTP responses with status >= 400 to an instance of \OpenSearch\Exception\HttpExceptionInterface which extends \OpenSearch\Exception\OpenSearchExceptionInterface.

acbramley’s picture

Status: Needs review » Needs work

That doesn't work for the original issue in the IS (it's still GuzzleHttp\Exception\ConnectException)

kim.pepper’s picture

Hmm. What version of opensearch-php are you using?

Ah you are right, because we don't catch \Psr\Http\Client\ClientExceptionInterface anywhere.

kim.pepper’s picture

Status: Needs work » Needs review

Updated to catch both OpenSearchExceptionInterface and ClientExceptionInterface

acbramley’s picture

Cool! Just need to fix phpcs (again) :)

  • kim.pepper committed 8cde3947 on 3.x authored by acbramley
    Issue #3530261 by acbramley, kim.pepper: Catch ClientExceptionInterface...

  • kim.pepper committed 3ad7eb89 on 2.x
    Issue #3530261 by acbramley, kim.pepper: Catch ClientExceptionInterface...
kim.pepper’s picture

Status: Needs review » Fixed

Committed to 3.x and 2.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.