getmoto / moto

A library that allows you to easily mock out tests based on AWS infrastructure.

Home Page:http://docs.getmoto.org/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DynamoDB Table batch_writer does not error on duplicate keys

jagoodhand opened this issue · comments

Problem: moto doesn't throw an error when you attempt to write duplicate keys to a dynamodb table using the table batch_writer.

How to reproduce the issue: Batch write multiple same keys to a dynamodb table.

What I expect to happen: boto3 should throw an error when you attempt to batch_write with duplicate keys:

An error occurred (ValidationException) when calling the BatchWriteItem operation: Provided list of item keys contains duplicates

What actually happens: No error is thrown. All items are written, the last item overwrites any previous keys.

Versions:
moto - 5.0.4
boto3 - 1.34.73
botocore - 1.34.73

Installed using poetry, executed using python mocks.

I think that the same problem occurs with the batch_get method, but I haven't had a chance to double check

@bblommers I can take a look

@jagoodhand batch_get has the logic to catch dupes, ☝️ PR should fix it for writes.

Thanks for the effort to implement a speedy fix @rafcio19 !