Pouyan
Pouyan

Reputation: 85

endless dead letter queue (DLQ) processing when Middy.js SQS queue validator fails

I've got a lambda handler that processes incoming SQS events. There is a middyJs handler with a validator middleware on top of that. When MiddyJs validation fails the event gets stuck in an endless loop inside DLQ.
When I throw an Error intentionally inside the handler it appears on DLQ just once. but with MiddyJs validation, it'll run through an endless loop.
Does anyone know what might cause this behavior?

The middy configuration is as follows:

middy(
  sqsEventLambdaHandler,
)
  .use(eventNormalizerMiddleware())
  .use(
    validator({
      eventSchema: transpileSchema(sqsEventLambdaEventSchema),
    }),
  )
  .use(sqsPartialBatchFailure());

And here is the error from cloudwatch:

Unknown application error occurred
Runtime.Unknown

Upvotes: 0

Views: 285

Answers (1)

will Farrell
will Farrell

Reputation: 1759

@middy/sqs-partial-batch-failure is designed to work with a specific SQS configuration.

The value ReportBatchItemFailures must be added to your Lambda's FunctionResponseTypes in the EventSourceMapping.

https://middy.js.org/docs/middlewares/sqs-partial-batch-failure#important

Upvotes: 0

Related Questions