Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQSEventResponse with non-empty BatchItemFailures gets ignored #430

Closed
yerke opened this issue Mar 4, 2022 · 1 comment
Closed

SQSEventResponse with non-empty BatchItemFailures gets ignored #430

yerke opened this issue Mar 4, 2022 · 1 comment

Comments

@yerke
Copy link

yerke commented Mar 4, 2022

SQSEventResponse (that was introduced in #410 and is based on batchItemFailures) does not work as expected.

Specifically, the SQS messages do not end up being marked as failed, when you add the corresponding record ids to BatchItemFailures in SQSEventResponse.

My example code looks similar to the block below. I would expect all messages in a batch to fail in this example.

func HandleRequest(ctx context.Context, sqsEvent events.SQSEvent) (events.SQSEventResponse, error) {
	failedMessageIds := events.SQSEventResponse{}
	for _, message := range sqsEvent.Records {
		failedMessageIds.BatchItemFailures = append(failedMessageIds.BatchItemFailures, events.SQSBatchItemFailure{
			ItemIdentifier: message.MessageId,
		})
	}
	return failedMessageIds, nil
}

Returning error results in failing the whole batch. But events.SQSEventResponse seems to be ignored completely, and the batch is treated as successful every time. The expected behavior is that the messages with ids in BatchItemFailures should be be marked as failed, whereas the rest of the batch should marked as successfully processed.

Returning just events.SQSEventResponse instead of (events.SQSEventResponse, error) results in handler returns a single value, but it does not implement error error.

Part of my go.mod:

github.com/aws/aws-lambda-go v1.28.0
github.com/aws/aws-sdk-go v1.30.22

Am I doing something wrong?

@lyoung-confluent Does it work for you? Sorry to bother you, but you are most likely the most knowledgable person, since you contributed it.

@yerke yerke changed the title SQSEventResponse with non-empty BatchItemFailures get ignored SQSEventResponse with non-empty BatchItemFailures gets ignored Mar 4, 2022
@yerke
Copy link
Author

yerke commented Mar 5, 2022

Turns out that terraform didn't apply function_response_types = ["ReportBatchItemFailures"] change. After I reran Terraform with that change and made sure that it's been picked up, I see the correct behavior.

Screen Shot 2022-03-04 at 4 10 49 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant