Skip to content

[BUG] DynamoDB does not enforce the 2048/1024 byte key length limits #3323

Description

@rfoel

Service

DynamoDB

AWS API Action

PutItem (and anything else that writes a key)

Expected behavior

DynamoDB caps key lengths:

  • partition key value: 2048 bytes
  • sort key value: 1024 bytes

Going over either one is rejected with HTTP 400 ValidationException:

One or more parameter values were invalid: Size of hashkey has exceeded the maximum size limit of 2048 bytes

See https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ServiceQuotas.html#limits-partition-sort-keys

AWS-published DynamoDB Local 3.3.1 enforces both limits.

Actual behavior

Floci accepts oversized keys and stores the item. No error, and the item shows up in a later Scan.

This matters for tests that check how an application handles a non-retryable DynamoDB error. A common way to trigger one is to write a key that is too long. Against Floci the write succeeds, so the test passes for the wrong reason or fails because no error arrives.

Reproduction

# partition key: 2100 bytes, limit is 2048
aws dynamodb create-table --table-name repro-keysize \
  --attribute-definitions AttributeName=pk,AttributeType=S \
  --key-schema AttributeName=pk,KeyType=HASH \
  --billing-mode PAY_PER_REQUEST
aws dynamodb wait table-exists --table-name repro-keysize

BIG=$(printf "x%.0s" $(seq 1 2100))
aws dynamodb put-item --table-name repro-keysize --item "{\"pk\":{\"S\":\"$BIG\"}}"
aws dynamodb scan --table-name repro-keysize --select COUNT --query Count --output text

Real AWS and DynamoDB Local: ValidationException.
Floci: exit code 0, and the scan returns 1.

The sort key behaves the same way:

# sort key: 1100 bytes, limit is 1024
aws dynamodb create-table --table-name repro-sk \
  --attribute-definitions AttributeName=pk,AttributeType=S AttributeName=sk,AttributeType=S \
  --key-schema AttributeName=pk,KeyType=HASH AttributeName=sk,KeyType=RANGE \
  --billing-mode PAY_PER_REQUEST
aws dynamodb wait table-exists --table-name repro-sk

SK=$(printf "y%.0s" $(seq 1 1100))
aws dynamodb put-item --table-name repro-sk --item "{\"pk\":{\"S\":\"a\"},\"sk\":{\"S\":\"$SK\"}}"
aws dynamodb scan --table-name repro-sk --select COUNT --query Count --output text

Same result: accepted and stored.

Environment

  • Floci version / image tag: 2.0.1, floci/floci:latest (sha256:4e451c39c7bb88e3cd4f87e8fc0c25d5b47695a51185d521e2241fa00486e8eb)
  • Java SDK version (if applicable): n/a, reproduced with AWS CLI v2 and @aws-sdk/client-dynamodb v3
  • How you're running Floci: Docker, via docker compose

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdynamodbAmazon DynamoDB

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions