'LocalStack fails for mocking send email endpoint through AWS SES SDK in Java

I'm making use of LocalStack to mock AWS SES for testing. I'm making use of LocalStack through it's docker image. I've mocked AWS by overriding it's endpoint during AWS SES client creation:

AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder.standard()
            .withEndpointConfiguration(new EndpointConfiguration(awsEndpoint, region))
            .withCredentials(awsCredentials)
            .build();

AWS CLI (atleast for SES) works correctly with LocalStack (by providing it the endpoint of LocalStack through the --endpoint-url parameter) when it comes to identity creation, listing and sending emails. However, the send email based SDK calls fail when hit programmatically through the Java based AWS SES SDK. Whenever such a call is made, LocalStack throws the following error:

2022-04-26T11:30:17.625:WARNING:localstack.utils.server.http2_server: Error in proxy handler for request POST http://localhost:4566/: object of type 'NoneType' has no len() Traceback (most recent call last):
  File "/opt/code/localstack/localstack/utils/server/http2_server.py", line 185, in index
    result = await run_sync(handler, request, data)
  File "/opt/code/localstack/localstack/utils/asyncio.py", line 85, in run_sync
    return await loop.run_in_executor(thread_pool, copy_context().run, func_wrapped)
  File "/opt/code/localstack/localstack/utils/threads.py", line 38, in run
    result = self.func(self.params, **kwargs)
  File "/opt/code/localstack/localstack/utils/asyncio.py", line 30, in _run
    return fn(*args, **kwargs)
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 972, in handler
    return modify_and_forward(
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 516, in wrapper
    value = func(*args, **kwargs)
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 596, in modify_and_forward
    listener_result = listener.forward_request(
  File "/opt/code/localstack/localstack/services/edge.py", line 178, in forward_request
    result = do_forward_request(api, method, path, data, headers, port=port)
  File "/opt/code/localstack/localstack/services/edge.py", line 233, in do_forward_request
    result = do_forward_request_inmem(api, method, path, data, headers, port=port)
  File "/opt/code/localstack/localstack/services/edge.py", line 257, in do_forward_request_inmem
    response = modify_and_forward(
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 516, in wrapper
    value = func(*args, **kwargs)
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 596, in modify_and_forward
    listener_result = listener.forward_request(
  File "/opt/code/localstack/localstack/http/adapters.py", line 38, in forward_request
    response = self.request(request)
  File "/opt/code/localstack/localstack/aws/proxy.py", line 42, in request
    response = self.skeleton.invoke(context)
  File "/opt/code/localstack/localstack/aws/skeleton.py", line 153, in invoke
    return self.dispatch_request(context, instance)
  File "/opt/code/localstack/localstack/aws/skeleton.py", line 165, in dispatch_request
    result = handler(context, instance) or {}
  File "/opt/code/localstack/localstack/aws/forwarder.py", line 57, in _call
    return handler(context, req)
  File "/opt/code/localstack/localstack/aws/skeleton.py", line 117, in __call__
    return self.fn(*args, **kwargs)
  File "/opt/code/localstack/localstack/aws/api/core.py", line 95, in operation_marker
    return fn(*args, **kwargs)
  File "/opt/code/localstack/localstack/services/ses/provider.py", line 258, in send_raw_email
    message = ses_backend.send_raw_email(source, destinations, raw_data, context.region)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/ses/models.py", line 258, in send_raw_email
    recipient_count = len(destinations)
TypeError: object of type 'NoneType' has no len()

I'm not sure what exactly is causing the error. Note that the same send email based SDK call works perfectly with the real AWS. This is the source of my confusion and doubt : Why exactly is LocalStack behaving in this way? It mocks the send email call made through AWS CLI perfectly but fails to do so with AWS SES SDK based call. I'm using SES version 1 SDK from AWS. I hope you all can help me out with this doubt of mine.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source