You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR fixes an issue where the persistence-elastic hook fails on Elasticsearch 8 because the bulk API response is no longer wrapped in a .body property (as it was in Elasticsearch 7). This results in bulkResponse.body being undefined, preventing proper error checks and breaking bulk indexing for ES 8.
This change normalises the bulk response format so it works for both ES 7 and ES 8 by:
Executing client.bulk({ refresh: true, body })
Detecting whether the response is wrapped (response.body) or unwrapped (response)
Using the correct structure in each case
Preserving backwards compatibility with ES 7
Adding a unit test to validate ES 8-style behaviour
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
# Description
This PR fixes an issue where the
persistence-elastichook fails on Elasticsearch 8 because the bulk API response is no longer wrapped in a.bodyproperty (as it was in Elasticsearch 7). This results inbulkResponse.bodybeingundefined, preventing proper error checks and breaking bulk indexing for ES 8.This change normalises the bulk response format so it works for both ES 7 and ES 8 by:
client.bulk({ refresh: true, body })response.body) or unwrapped (response)Fixes #3385
# Checklist
General
Fixes #3385).Signed-off-byline for DCO compliance.Testing
I ran the existing test suite for the persistence-elastic hook.
Command used:
PATH=$HOME/.bun/bin:$PATH bun test
I added a unit test for the ES 8 bulk response format.
Tests pass locally.
Documentation / Misc
# Types of Changes
# Screenshots / Logs (optional)
N/A — behaviour validated through unit tests.