Problem/Motivation
When I first setup Elasticsearch using this module, I ran into an error while indexing. When I checked the log, all I saw was this:
Drupal\search_api\SearchApiException while trying to index items on index Paragraphs Index: An error occurred during indexing. Check your watchdog for more information. in Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend->indexItems() (line 508 of /app/web/modules/contrib/elasticsearch_connector/src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php)
I didn't see any other, more specific information about the error in the log, which this error seems to elude to. Enabling the debugger, and dropping a breakpoint in the spot of the thrown exception allowed me to see what was happening. The error I was receiving:
status: 403
type: cluster_block_exception
reasion: blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
However, the error itself is not logged unless the code == '400':
$item['index']['status'] == '400'
So these 403 errors don't get logged, because '400' != 403. Obviously there is some misconfiguration in my local Elasticsearch server. But the motivation for this issue is to provide more helpful debugging information up front.
I will also point out that this status code value appears to be an integer, and not a string as it's compared to.
Proposed resolution
I suggest we cast the status code to a string, and compare whether the status code is within the 400 (or 500?) range.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | elasticsearch_connector-6.x-error_codes-3176523-3.patch | 969 bytes | bburg |
| #2 | elasticsearch_connector-7.x-error_codes-3176523-2.patch | 968 bytes | bburg |
Comments
Comment #2
bburgStarting with head, 8.x-7.x branch patch.
8.x-6.x patch coming.
Comment #3
bburgComment #4
bburgFor some reason, these patch files aren't lining up with the versions I thought they were for...Nevermind, I was trying to patch an already patched file. Should be good to go.
Comment #5
sokru commentedWill add this to next release.
Comment #6
sokru commentedI'll add
'%caused_by' => $item['index']['error']['caused_by']['reason'] ?? '',on commit stage.Comment #8
sokru commentedThanks @bburg, not sure how come I was not able to commit to 8.x-6.x branch, and I have no intentions to maintain deprecated version. But if I are willing to open a merge request for 8.x-6.x I'm happy to merge it.