Search code examples
aws-sdkamazon-sqs

AWS-SDK issue w/ deleteMessageBatch, telling me MissingParameter but I'm not


I'm getting the following message

UnhandledPromiseRejectionWarning: MissingParameter: The request must contain the parameter DeleteMessageBatchRequestEntry.1.Id.

I think I'm following the documentation to a T at AWS-SDK/SQS

I'm using this code

var params = {
          Entries: _.map(_.uniqWith(data.Messages,d=>d.MessageId),d=>({
            Id: d.MessageId,
            ReceiptHandle: d.ReceiptHandle
          })),
          QueueUrl: xx.QueueUrl
        };
await sqs.deleteMessageBatch(params).promise();

This is what params looks like at the time of sending; looks just like the docs if you ask me...

{ 
    Entries: [
      {
        Id: "83ba1e18-someid", 
        ReceiptHandle: "AQEB79CDI1Q+blablabla"
      }
    ]
    QueueUrl: "https://sqs.us-west-2.amazonaws.com/somequeeuurl"
}

My system:

aws-sdk: "^2.354.0",
MacOS - current
node 8.12.0

Solution

  • UnhandledPromiseRejectionWarning: MissingParameter: The request must contain the parameter DeleteMessageBatchRequestEntry.1.Id.

    I just spent a long time looking at this error and debugging my code. What I finally figured out is that it seems to be trying to say that there needs to be at least one DeleteMessageBatchRequestEntry element in the request – there can't be 0. When I refactored our code and added a check to make sure that we wouldn't make a request if there were no entries in the list, this problem went away.

    Is it possible that you are actually sending the following in certain situations?

    { 
        Entries: []
        QueueUrl: "https://sqs.us-west-2.amazonaws.com/somequeeuurl"
    }