Carry the notification subject on SNS batch entries - #1704
Open
anjeongkyun wants to merge 1 commit into
Open
Conversation
The subject header is skipped when building message attributes, on the assumption that it is set on the request instead. The single publish and async paths do set it; the batch converter never did, so the subject was dropped. Also fixes a duplicated assertion in SequentialBatchExecutionStrategy that checked topicArn twice and left entries unvalidated.
anjeongkyun
requested review from
MatejNedic,
maciejwalkowiak and
tomazfernandes
as code owners
September 13, 2026 07:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📢 Type of change
📜 Description
SnsHeaderConverterUtil.isSkipHeaderleavesNOTIFICATION_SUBJECT_HEADERout of the message attributes, because the subject belongs on the request rather than in the attribute map:Two of the three publish paths then set it:
TopicMessageChannel.sendInternalcalls.subject(findNotificationSubject(message))DefaultSnsPublishMessageConverter.populateHeaderssetspublishRequest::subjectDefaultSnsMessageConverter(batch) never mentions the subject.PublishBatchRequestEntryhas asubjectfield, so nothing fails - the header is excluded from the attributes and never put on the entry, and the subject is silently gone. The FIFO headers next to it are already handled in all three paths, which is what made the gap visible.So the same message sent through
SnsTemplatereaches subscribers with a subject, and throughSnsBatchTemplatewithout one. Email subscribers get an empty subject line.The change follows
DefaultSnsPublishMessageConverter, the closest sibling, and reads the header as aStringrather than callingtoString()on it the wayTopicMessageChanneldoes.This PR also carries a one-line fix in the same subpackage:
SequentialBatchExecutionStrategy.sendassertstopicArntwice and never checksentries.Happy to split that into its own PR if you would rather keep this one to the subject.
💡 Motivation and Context
Both came in with the batch template in #1574 and neither is covered by a test today.
💚 How did you test it?
Added
setsNotificationSubjecttoDefaultSnsMessageConverterTest, which checks the subject lands on the entry and does not leak into the message attributes. It fails on currentmainand passes with the change. ExtendedleavesOptionalHeadersNullWhenAbsentto cover the subject alongside the FIFO headers it already asserts.spring-cloud-aws-snspasses in full (119 tests).📝 Checklist
The SNS reference docs describe the payload types the batch template supports and do not enumerate headers, so there is nothing there to correct.
🔮 Next steps
While reading this code I noticed
SnsAsyncTopicArnResolver.resolveTopicArncalls.join()when it is given a topic name rather than an ARN, which blocks the caller ofSnsAsyncTemplate.TopicArnResolveris a synchronous interface, so changing that is an API question rather than a fix. I can open an issue if it is worth discussing.