Skip to content

Include failure details in SendBatchOperationFailedException message#1608

Open
krechanski wants to merge 3 commits into
awspring:mainfrom
krechanski:fix-send-batch-operation-failed-exception-failure-mesage
Open

Include failure details in SendBatchOperationFailedException message#1608
krechanski wants to merge 3 commits into
awspring:mainfrom
krechanski:fix-send-batch-operation-failed-exception-failure-mesage

Conversation

@krechanski
Copy link
Copy Markdown

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

SendBatchOperationFailedException was constructed with an empty message string, making it impossible to diagnose batch send failures from the exception message alone. The message now includes the number of failed vs total messages, the target endpoint, the failed message IDs, and the error messages from AWS.

💡 Motivation and Context

When a batch send partially fails, the thrown exception carried no useful information in its message. Callers relying on logging or error reporting had to inspect the exception object programmatically to understand what went wrong.

💚 How did you test it?

Added unit test shouldIncludeFailureDetailsInBatchExceptionMessage in SqsTemplateTests that simulates a partial batch failure and asserts the exception message contains the failed/total count, endpoint name, failed message ID, and error message.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated reference documentation to reflect the change
  • All tests passing
  • No breaking changes

🔮 Next steps

Run the full test suite to confirm no regressions.

@github-actions github-actions Bot added the component: sqs SQS integration related issue label Apr 20, 2026
Copy link
Copy Markdown
Contributor

@tomazfernandes tomazfernandes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krechanski, thanks for the PR, left a couple of comments.

private <T> CompletableFuture<SendResult.Batch<T>> handleFailedSendBatch(String endpoint,
SendResult.Batch<T> result) {
return CompletableFuture.failedFuture(new SendBatchOperationFailedException("", endpoint, result));
SendResult.Batch<T> result) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not use spaces to align, you can run mvn spotless:apply to fix this.

result.failed().size() + result.successful().size(), endpoint,
MessageHeaderUtils.getId(result.failed().stream().map(SendResult.Failed::message).toList()),
result.failed().stream().map(SendResult.Failed::errorMessage)
.collect(Collectors.joining("; "))), endpoint, result));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern here would be that we already use ; to join the ids in MessageHeaderUtils.getId().

How about we pair the ids with the corresponding error message instead?

Also, let's guard against a possibly null message.

@tomazfernandes
Copy link
Copy Markdown
Contributor

@MatejNedic, it seems the Validate Docs action is failing due to an issue in docs/src/main/asciidoc/parameter-store.adoc:289, introduced in PR #1298.

Would you mind fixing it so we have a green docs build?

@MatejNedic
Copy link
Copy Markdown
Member

MatejNedic commented May 4, 2026

@tomazfernandes fix is in main. Rebase against main and we are good!

@tomazfernandes
Copy link
Copy Markdown
Contributor

Thanks @MatejNedic for the fix.

@krechanski, if you can rebase onto the updated main so we pull it in, thanks.

@tomazfernandes tomazfernandes added the status: waiting-for-feedback Waiting for feedback from issuer label May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: sqs SQS integration related issue status: waiting-for-feedback Waiting for feedback from issuer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants