Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

dynamodb client.batch_get_item() fails in case keys contains duplicates #4131

Closed
kanishthkarthik opened this issue May 16, 2024 · 2 comments
Closed
Assignees
Labels
bug This issue is a confirmed bug. dynamodb service-api This issue is caused by the service API, not the SDK implementation.

Comments

@kanishthkarthik
Copy link

kanishthkarthik commented May 16, 2024

Describe the bug

Invoking batch_get_item with duplicate keys results in a ValidationException. I could not find a reference to this error either in the boto3 documentation or in the AWS Docs for BatchGetItem. Is this an expected behavior?

Expected Behavior

A ValidationException is not raised or the behavior is documented.

Current Behavior

Invoking batch_get_item with duplicate keys results in a ValidationException.

Reproduction Steps

import boto3

keys = [{'id': {'S': key}} for key in ['id1', 'id1', 'id2']]

client = boto3.client('dynamodb', region_name='us-east-1')
response = client.batch_get_item(
    RequestItems={'IdTable': {'Keys': keys}},
)

The above snippet raises: ClientError: An error occurred (ValidationException) when calling the BatchGetItem operation: Provided list of item keys contains duplicates

Possible Solution

The behavior can be detailed in the documentation.

Additional Information/Context

No response

SDK version used

1.34.76

Environment details (OS name and version, etc.)

macOS 14.4.1

@kanishthkarthik kanishthkarthik added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels May 16, 2024
@tim-finnigan tim-finnigan self-assigned this May 17, 2024
@tim-finnigan tim-finnigan added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label May 17, 2024
@tim-finnigan
Copy link
Contributor

tim-finnigan commented May 17, 2024

Thanks for reaching out. This is the expected behavior. The Boto3 batch_get_item command involves a call to the underlying DynamoDB BatchGetItem API in which the ValidationException occurs. As mentioned in the documentation for Keys:

Keys - An array of primary key attribute values that define specific items in the table...

So Keys should correspond to specific items, and therefore duplicates cannot be used here. Hope that helps, if you have any follow up questions let us know. I'm going to convert this do a discussion as it is not a bug.

And if you think the documentation could be improved here please use the Provide feedback at the bottom of the API documentation page to reach the appropriate team. Any updates to the API docs will be updated in Boto3 automatically.

@tim-finnigan tim-finnigan added dynamodb service-api This issue is caused by the service API, not the SDK implementation. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. needs-triage This issue or PR still needs to be triaged. labels May 17, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@boto boto locked and limited conversation to collaborators May 17, 2024
@tim-finnigan tim-finnigan converted this issue into discussion #4135 May 17, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug This issue is a confirmed bug. dynamodb service-api This issue is caused by the service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

2 participants