Skip to content

Fix SigV4 signing failure on bulk retry after partial success - #759

Merged
lawofcycles merged 2 commits into
opensearch-project:mainfrom
lawofcycles:fix/sigv4-bulk-retry
May 16, 2026
Merged

Fix SigV4 signing failure on bulk retry after partial success#759
lawofcycles merged 2 commits into
opensearch-project:mainfrom
lawofcycles:fix/sigv4-bulk-retry

Conversation

@lawofcycles

@lawofcycles lawofcycles commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Description

Fix SigV4 signing failure that occurs when a bulk request is retried after partial success.

TrackingBytesArray.toInputStream() returned the entire underlying byte array including bytes of removed entries, while writeTo() correctly skipped them. After a partial bulk success, BulkProcessor removes successfully indexed entries from the buffer and retries the rest. On retry, AwsV4SignerSupport computes the content SHA256 from toInputStream() (stale data), but the HTTP body is sent via writeTo() (correct data). The mismatch causes the server to reject the request with 403: Request header x-amz-content-sha256 invalid.

This fix changes toInputStream() to use the same entry traversal logic as writeTo(), ensuring both methods always return the same byte sequence.

Issues Resolved

Closes #758

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@lawofcycles
lawofcycles force-pushed the fix/sigv4-bulk-retry branch 3 times, most recently from 08a1f2b to 4f42b9a Compare May 12, 2026 16:24
TrackingBytesArray.toInputStream() returned the entire underlying byte
array including bytes of removed entries, while writeTo() correctly
skipped them. This caused a mismatch between the x-amz-content-sha256
header (computed from toInputStream()) and the actual HTTP body (sent
via writeTo()) when retrying a bulk request after partial success.

Changed toInputStream() to build its result using the same entry
traversal logic as writeTo().

Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
@lawofcycles
lawofcycles force-pushed the fix/sigv4-bulk-retry branch from 4f42b9a to dae4eee Compare May 14, 2026 22:42
Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
@lawofcycles
lawofcycles merged commit c5c3ca3 into opensearch-project:main May 16, 2026
15 checks passed
@lawofcycles

Copy link
Copy Markdown
Collaborator Author

@Xtansia Thank you for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] SigV4 signing fails on bulk retry after partial success (x-amz-content-sha256 mismatch)

2 participants