Skip to content

AWS dynamodb.BatchWriteItem => 500 (InternalError) when DYNAMODB_ERROR_PROBABILITY set. #7597

@Yliu12

Description

@Yliu12

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Dynamodb Batch write request throws 500 error when DYNAMODB_ERROR_PROBABILITY is set to >0

Stack trace below

2023-02-01T21:50:21.918 ERROR --- [   asgi_gw_4] l.aws.handlers.logging     : exception during call chain
2023-02-01 13:50:22 Traceback (most recent call last):
2023-02-01 13:50:22   File "/opt/code/localstack/localstack/aws/chain.py", line 90, in handle
2023-02-01 13:50:22     handler(self, self.context, response)
2023-02-01 13:50:22   File "/opt/code/localstack/localstack/aws/handlers/service.py", line 122, in __call__
2023-02-01 13:50:22     handler(chain, context, response)
2023-02-01 13:50:22   File "/opt/code/localstack/localstack/aws/handlers/service.py", line 92, in __call__
2023-02-01 13:50:22     skeleton_response = self.skeleton.invoke(context)
2023-02-01 13:50:22   File "/opt/code/localstack/localstack/aws/skeleton.py", line 153, in invoke
2023-02-01 13:50:22     return self.dispatch_request(context, instance)
2023-02-01 13:50:22   File "/opt/code/localstack/localstack/aws/skeleton.py", line 165, in dispatch_request
2023-02-01 13:50:22     result = handler(context, instance) or {}
2023-02-01 13:50:22   File "/opt/code/localstack/localstack/aws/forwarder.py", line 56, in _call
2023-02-01 13:50:22     return handler(context, req)
2023-02-01 13:50:22   File "/opt/code/localstack/localstack/aws/skeleton.py", line 117, in __call__
2023-02-01 13:50:22     return self.fn(*args, **kwargs)
2023-02-01 13:50:22   File "/opt/code/localstack/localstack/aws/api/core.py", line 151, in operation_marker
2023-02-01 13:50:22     return fn(*args, **kwargs)
2023-02-01 13:50:22   File "/opt/code/localstack/localstack/services/dynamodb/provider.py", line 860, in batch_write_item
2023-02-01 13:50:22     unprocessed_items[table_name].append({key: unprocessed_items[key]})
2023-02-01 13:50:22 KeyError: 'Snapshots'
2023-02-01 13:50:22 2023-02-01T21:50:21.919  INFO --- [   asgi_gw_4] localstack.request.aws     : AWS dynamodb.BatchWriteItem => 500 (InternalError)

Expected Behavior

Not throwing 500 error. only 400 (ProvisionedThroughputExceededException) is expected.

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

docker run localstack/localstack

under environment set

DYNAMODB_ERROR_PROBABILITY=0.5

Or with local stack cli
DEBUG=1 DYNAMODB_ERROR_PROBABILITY=0.5 localstack start -d

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

through java client
dynamoDbClient.batchWriteItem(batchRequest)
I believe it's the same for any client.since it's 500 error

Environment

- OS:macos 13.2
- LocalStack: latest

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions