Skip to content

BatchWriteItemResponse#unprocessedItems not usable for retry #1619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zbytt opened this issue Feb 4, 2025 · 1 comment
Open

BatchWriteItemResponse#unprocessedItems not usable for retry #1619

zbytt opened this issue Feb 4, 2025 · 1 comment

Comments

@zbytt
Copy link

zbytt commented Feb 4, 2025

Issue

Assuming usage of Java & DynamoDbClient with properly configured DynamoDbEncryptionInterceptor.

In cases where BatchWriteRequest that contains some PutRequests items, if any of those item is then returned in BatchWriteItemResponse#unprocessedItems - it cannot be used for further processing. (i.e. retry)

Invalid case for retry using DynamoDbClient:
BatchWriteItemResponse#unprocessedItems put requests contain encryption headers, so if item is reused as is encryption interceptor throws :
software.amazon.cryptography.dbencryptionsdk.dynamodb.transforms.model.DynamoDbEncryptionTransformsException: Writing reserved attributes not allowed : aws_dbe_foot,aws_dbe_head

Invalid case for retry using DynamoDbEnhancedClient:
If DynamoDbEnhancedClient is used to unconvert unprocessedItems attribute values to java type (using software.amazon.awssdk.enhanced.dynamodb.model.BatchWriteResult#unprocessedPutItemsForTable) - encryption headers are removed, mapping succeeds but attributes that were encrypted by interceptor are broken.
In my case I have a String attribute defined, which is then encrypted by interceptor. Usage of BatchWriteResult#unprocessedPutItemsForTable unconverts encrypted byte array to String leaving me with base64 encrypted value instead of the initial String value that was put to BatchWriteItemEnhancedRequest.

Workaround
I put custom interceptor before DynamoDbEncryptionInterceptor. It stores initial BatchWriteRequest#PutRequest items and in case of #unprocessesItems returned in batch response I replace encrypted values with the stored ones.

@ajewellamz
Copy link
Contributor

Fixed in #1642, so this will be in the next release.

I have no idea when the next release might be.

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

No branches or pull requests

3 participants