8000 persistence-elastic: handle es8 bulk response by conleth · Pull Request #3391 · secureCodeBox/secureCodeBox · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@conleth
Copy link
Contributor
@conleth conleth commented Nov 25, 2025

# Description

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

Fixes #3385


# Checklist

General

  • I have clearly described what this PR changes and why.
  • I have linked the related issue (Fixes #3385).
  • I have added myself to the contributors file.
  • All commits include a Signed-off-by line 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

  • No new files were added, so no SPDX header was required.
  • This PR follows GitHub Flow (feature/bugfix branch → PR → review → merge).

# Types of Changes

  • Bug Fix — Resolves failure in the persistence-elastic hook when handling ES 8 bulk responses.

# Screenshots / Logs (optional)

N/A — behaviour validated through unit tests.

@netlify
Copy link
netlify bot commented Nov 25, 2025

Deploy Preview for docs-securecodebox ready!

Name Link
🔨 Latest commit 9d39ea9
🔍 Latest deploy log https://app.netlify.com/projects/docs-securecodebox/deploys/693862376fddcf0008f8b564
😎 Deploy Preview https://deploy-preview-3391--docs-securecodebox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@J12934
Copy link
Member
J12934 commented Dec 3, 2025

Hi @conleth,
the change looks ok to me :)

The description says: " All commits include a Signed-off-by line for DCO compliance." but thats not the case :D
can you have a look at the DCO bot for instructions to fix that? https://github.com/secureCodeBox/secureCodeBox/pull/3391/checks?check_run_id=56373070867

Signed-off-by: conleth <conlethkennedy@gmail.com>
Signed-off-by: conleth <conlethkennedy@gmail.com>
Signed-off-by: conleth <conlethkennedy@gmail.com>
@conleth conleth force-pushed the bugfix/persistence-elastic-es8-response branch from 1766837 to 7618b71 Compare December 9, 2025 17:43
@sonarqubecloud
Copy link
sonarqubecloud bot commented Dec 9, 2025

@conleth
Copy link
Contributor Author
conleth commented Dec 9, 2025

Hi @conleth, the change looks ok to me :)

The description says: " All commits include a Signed-off-by line for DCO compliance." but thats not the case :D can you have a look at the DCO bot for instructions to fix that? https://github.com/secureCodeBox/secureCodeBox/pull/3391/checks?check_run_id=56373070867

Updated and fix the duplicate code issue from the quality gate.

@github-project-automation github-project-automation bot moved this from Triage to Reviewer Approved in secureCodeBox Dec 10, 2025
@J12934 J12934 merged commit 5dd8fd6 into secureCodeBox:main Dec 10, 2025
48 checks passed
@github-project-automation github-project-automation bot moved this from Reviewer Approved to Done in secureCodeBox Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Elasticsearch 8.x compatibility issue: persistence-elastic hook fails with TypeError on bulk indexing

2 participants

0