Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda Report batch item failures with SQS

The Lambda response is

{
  "errorMessage": "handler returns a single value, but it does not implement error",
  "errorType": "errorString"
}

ref aws document

The example shows that only need to return fail messages without error.

And I have enabled the Report batch item failure option in Lambda trigger.

My golang code in lambda is like

type SQSBatchResponse struct {
    BatchItemFailures []SQSMessage 
}

type SQSMessage struct {
    MessageId string
}

func Handler(_ context.Context, sqsEvent events.SQSEvent) (sqsResponse SQSBatchResponse) {
    // code
    return sqsResponse
}
like image 443
Coffeey Avatar asked Feb 19 '26 13:02

Coffeey


1 Answers

It seems that the response structure should be like this.

Aws-lambda-go

type SQSEventResponse struct {
    BatchItemFailures []SQSBatchItemFailure `json:"batchItemFailures"`
}

type SQSBatchItemFailure struct {
    ItemIdentifier string `json:"itemIdentifier"`
}
like image 59
brian goo Avatar answered Feb 24 '26 05:02

brian goo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!