Skip to content

Empty DeleteMessageBatch error message #169

@jplock

Description

@jplock

What were you trying to accomplish?

I'm using the new SQS message processor and I'm seeing a lot of these:

[ERROR] EmptyBatchRequest: An error occurred (AWS.SimpleQueueService.EmptyBatchRequest) when calling the DeleteMessageBatch operation: There should be at least one DeleteMessageBatchRequestEntry in the request.
Traceback (most recent call last):
  File "/opt/python/aws_lambda_powertools/metrics/metrics.py", line 144, in decorate
    response = lambda_handler(event, context)
  File "/opt/python/aws_lambda_powertools/tracing/tracer.py", line 282, in decorate
    response = lambda_handler(event, context)
  File "/opt/python/aws_lambda_powertools/logging/logger.py", line 246, in decorate
    return lambda_handler(event, context)
  File "/opt/python/aws_lambda_powertools/middleware_factory/factory.py", line 130, in wrapper
    response = middleware()
  File "/opt/python/aws_lambda_powertools/utilities/batch/sqs.py", line 179, in sqs_batch_processor
    processor.process()
  File "/opt/python/aws_lambda_powertools/utilities/batch/base.py", line 58, in __exit__
    self._clean()
  File "/opt/python/aws_lambda_powertools/utilities/batch/sqs.py", line 118, in _clean
    delete_message_response = self.client.delete_message_batch(QueueUrl=queue_url, Entries=entries_to_remove)
  File "/opt/python/botocore/client.py", line 337, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/opt/python/aws_xray_sdk/ext/botocore/patch.py", line 38, in _xray_traced_botocore
    return xray_recorder.record_subsegment(
  File "/opt/python/aws_xray_sdk/core/recorder.py", line 435, in record_subsegment
    return_value = wrapped(*args, **kwargs)
  File "/opt/python/botocore/client.py", line 656, in _make_api_call
    raise error_class(parsed_response, operation_name)

in my logs.

Expected Behavior

No errors in logs about empty messages.

Current Behavior

Errors in logs about empty messages when calling SQS batch delete message.

Possible Solution

Maybe we could add a simple check around entries_to_remove to ensure it contains any entries before calling
delete_message_batch?

Steps to Reproduce (for bugs)

  1. have only a single message in the queue
  2. set the BatchSize to one so the Lambda only receives a single record
  3. Have the record_handler throw an exception

Environment

  • Powertools version used: 1.5.0
  • Packaging format (Layers, PyPi): Layers
  • AWS Lambda function runtime: Python 3.8
  • Debugging logs

How to enable debug mode**

# paste logs here

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneed-more-informationPending information to continue

Type

No type

Projects

Status

Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions