Admiral-Piett / goaws

AWS (SQS/SNS) Clone for Development testing
MIT License
788 stars 146 forks source link

SQS: EmptyBatchRequest error with slightly older @aws-sdk/client-sqs package (e.g. 3.445.0) #331

Open mattcobley opened 1 month ago

mattcobley commented 1 month ago

Hi,

When using this service with a slightly older version of the AWS SDK (e.g. 3.445.0) we get an error like the following when receiving some SQS messages (note that here we're manually calling send on the SQS client with a DeleteMessageBatchCommand). This works with the real AWS SQS service.

const entries = [
  {
    Id: '309ef453-bf32-42c5-a45e-2e1c2083e5af',
    ReceiptHandle: '309ef453-bf32-42c5-a45e-2e1c2083e5af#fd721ed5-6317-437e-8f23-1b3bdb20bc53'
  }
]
client.send(new DeleteMessageBatchCommand({ Entries: entries, QueueUrl: queueUrl }))

EmptyBatchRequest: UnknownError
    at de_EmptyBatchRequestRes (/opt/nodeservice/node_modules/@aws-sdk/client-sqs/dist-cjs/protocols/Aws_query.js:1036:23)
    at de_DeleteMessageBatchCommandError (/opt/nodeservice/node_modules/@aws-sdk/client-sqs/dist-cjs/protocols/Aws_query.js:498:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /opt/nodeservice/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
    at async /opt/nodeservice/node_modules/@aws-sdk/client-sqs/node_modules/@aws-sdk/middleware-signing/dist-cjs/awsAuthMiddleware.js:14:20
    at async /opt/nodeservice/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
    at async /opt/nodeservice/node_modules/@aws-sdk/client-sqs/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26
    at ... {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: undefined,
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  Error: {
    Type: 'EmptyBatchRequest',
    Code: 'AWS.SimpleQueueService.EmptyBatchRequest',
    Message: "The batch request doesn't contain any entries.",
    message: "The batch request doesn't contain any entries."
  },
  RequestId: '00000000-0000-0000-0000-000000000000'
}
Admiral-Piett commented 1 month ago

Hm, this looks like it should work I think. What version of GoAWS are you on?

mattcobley commented 1 month ago

Hm, this looks like it should work I think. What version of GoAWS are you on?

Thanks for the response. v0.5.0, I believe.

Admiral-Piett commented 1 month ago

Hm, I'll see if I can recreate it. Thanks!

Admiral-Piett commented 3 weeks ago

@mattcobley thanks for bringing this to our attention! Definitely a problem here. 🤦 I just put up a PR for it - https://github.com/Admiral-Piett/goaws/pull/336 That should take care of it I think. It'll be out in v0.5.2, I'll let you know when it's out.