Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
I get an 500 error from localstack when calling SnsAsyncClient.publishBatch on the Java AWS SDK with a malformed query. I had forgot to set the dataType field on the MessageAttributeValue. Real AWS gives back an error stating that the dataType field is required. Local stack returns a 500 with the stacktrace below:
Traceback (most recent call last):
File "/opt/code/localstack/.venv/lib/python3.11/site-packages/rolo/gateway/chain.py", line 166, in handle
handler(self, self.context, response)
File "/opt/code/localstack/localstack-core/localstack/aws/handlers/service.py", line 113, in __call__
handler(chain, context, response)
File "/opt/code/localstack/localstack-core/localstack/aws/handlers/service.py", line 83, in __call__
skeleton_response = self.skeleton.invoke(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/code/localstack/localstack-core/localstack/aws/skeleton.py", line 154, in invoke
return self.dispatch_request(serializer, context, instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/code/localstack/localstack-core/localstack/aws/skeleton.py", line 168, in dispatch_request
result = handler(context, instance) or {}
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/code/localstack/localstack-core/localstack/aws/forwarder.py", line 133, in _call
return handler(context, req)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/code/localstack/localstack-core/localstack/aws/skeleton.py", line 118, in __call__
return self.fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/code/localstack/localstack-core/localstack/services/sns/provider.py", line 205, in publish_batch
total_batch_size += get_total_publish_size(message_payload, message_attributes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/code/localstack/localstack-core/localstack/services/sns/provider.py", line 1065, in get_total_publish_size
size += sum(
^^^^
File "/opt/code/localstack/localstack-core/localstack/services/sns/provider.py", line 1066, in <genexpr>
_get_byte_size(key) + sum(_get_byte_size(attr_value) for attr_value in attr.values())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/code/localstack/localstack-core/localstack/services/sns/provider.py", line 1066, in <genexpr>
_get_byte_size(key) + sum(_get_byte_size(attr_value) for attr_value in attr.values())
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/code/localstack/localstack-core/localstack/services/sns/provider.py", line 1052, in _get_byte_size
return len(to_bytes(payload))
^^^^^^^^^^^^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()
Expected Behavior
I expect LocalStack to give an 400 response with an error message stating that the dataType field is required.
How are you starting LocalStack?
With a docker run
command
Steps To Reproduce
It looks like the aws cli has protections against leaving the dataType field blank, so the only way to reproduce is probably through an SDK like Boto.
Environment
- OS: Ubuntu 20.04
- LocalStack version: 5.8.1
Anything else?
No response