Skip to content

DynamoDB - Sporadic ValidationException when calling the BatchGetItem operation: The provided key element does not match the schema #4709

@giladrv

Description

@giladrv

Describe the bug

Summary

We are observing sporadic ValidationException errors when calling DynamoDB BatchGetItem via boto3 / botocore (through PynamoDB) even though the request keys are valid and match the table schema.

The same request (same keys, same table, same IAM role) will usually succeed, but sometimes fail. When the failing batch is split into smaller batches or retried, the requests succeed immediately.

Error

ValidationException: The provided key element does not match the schema

This error occurs on BatchGetItem. The request is not retried automatically by botocore (as expected for validation errors).

Environment

•	AWS Lambda (Python 3.13)
•	Region: eu-central-1
•	DynamoDB table with single hash key (no sort key)
•	Hash key attribute type: S
•	boto3/botocore: (provided by Lambda)

What we have verified

•	Same AWS account, role, and region for successful and failing requests
•	Table key schema is correct and consistent
•	Hash key name and type match exactly (S)
•	No duplicate keys in the batch
•	Very small batch sizes can trigger the issue (e.g. 3 keys)
•	Individual GetItem calls succeed
•	The same keys succeed when retried or when split into smaller batches

Example

A batch request with multiple valid keys intermittently fails:

{
  "RequestItems": {
    "<table-name>": {
      "Keys": [
        {"id": {"S": "<uuid-1>"}},
        {"id": {"S": "<uuid-2>"}},
        {"id": {"S": "<uuid-3>"}}
      ]
    }
  }
}

The same keys succeed immediately when split:
• Batch 1: 1 key → success
• Batch 2: remaining keys → success

No schema, IAM, or request changes between attempts.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Request succeeds or returns meaningful and correct error message

Current Behavior

Schema mismatch error despite correct schema.

Reproduction Steps

We are not sure how to reproduce.

Possible Solution

No response

Additional Information/Context

No response

SDK version used

Lambda Python 3.13 runtime

Environment details (OS name and version, etc.)

Lambda Python 3.13 runtime

Metadata

Metadata

Labels

bugThis issue is a confirmed bug.dynamodbp3This is a minor priority issueresponse-requestedWaiting on additional information or feedback.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions