Unhandled exception in indexNeedsClearing

Created on 9 July 2024, 2 months ago
Updated 24 July 2024, about 2 months ago

Problem/Motivation

πŸ› The whole index gets cleared/deleted when any change in the search index configuration is imported/synced Needs work added the indexNeedsClearing function which checks an index's mapping to try and determine whether we need to clear and reindex.

However, the getMapping function requires a new level of access that may not be present on the user being authenticated with OpenSearch.

If the user doesn't have access to get mappings then saving an index in any way will result in a 503 with:

OpenSearch\Common\Exceptions\Forbidden403Exception: {"error":{"root_cause":[{"type":"security_exception","reason":"no permissions for [indices:admin/mappings/get] and User [name=writer, backend_roles=[], requestedTenant=null]"}],"type":"security_exception","reason":"no permissions for [indices:admin/mappings/get] and User [name=writer, backend_roles=[], requestedTenant=null]"},"status":403} in OpenSearch\Connections\Connection->process4xxError() (line 654 of /data/vendor/opensearch-project/opensearch-php/src/OpenSearch/Connections/Connection.php).

OpenSearch\Connections\Connection->OpenSearch\Connections\{closure}() (Line: 28)
React\Promise\FulfilledPromise->then() (Line: 65)
GuzzleHttp\Ring\Future\CompletedFutureValue->then() (Line: 341)
GuzzleHttp\Ring\Core::proxy() (Line: 260)
OpenSearch\Connections\Connection->OpenSearch\Connections\{closure}() (Line: 238)
OpenSearch\Connections\Connection->performRequest() (Line: 112)
OpenSearch\Transport->performRequest() (Line: 61)
OpenSearch\Namespaces\AbstractNamespace->performRequest() (Line: 524)
OpenSearch\Namespaces\IndicesNamespace->getMapping() (Line: 371)
Drupal\search_api_opensearch\SearchAPI\BackendClient->indexNeedsClearing() (Line: 225)

Steps to reproduce

Save an index with a user that doesn't have access to get mappings

Proposed resolution

Catch the exception, and just return TRUE since we can't do much without being able to get mappings.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia acbramley

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024