Add awsGeneratedTags field to S3Bucket in s3-event-notifications#7138
Merged
Conversation
Open
alextwoods
reviewed
Jul 13, 2026
alextwoods
left a comment
Collaborator
There was a problem hiding this comment.
Overall looking good!
This also needs a change log - you can create one with ./scripts/new-change
alextwoods
requested changes
Jul 13, 2026
e22d9fb to
ee45a15
Compare
Amazon S3 event notifications delivered to SNS, SQS, and Lambda now
include an `awsGeneratedTags` map on the `bucket` object when system
tags are enabled on the source bucket. The Java SDK model did not
round-trip this field, so consumers had to fall back to raw JSON
parsing to read the tags.
This change adds `Map<String, String> awsGeneratedTags` to `S3Bucket`
and threads it through the reader and writer:
* `S3Bucket`: adds `awsGeneratedTags` field with a getter, a new
four-argument constructor, and updates `equals`/`hashCode`/
`toString`. The pre-existing three-argument constructor is
preserved so existing callers are source- and behavior-compatible.
Tags are defensively copied on construction and returned as an
unmodifiable view.
* `DefaultS3EventNotificationReader`: parses `awsGeneratedTags` as
`Map<String, String>`. Absent field yields `null`. Null value
entries are preserved. Non-string values throw
`IllegalArgumentException` with a helpful message including the
offending key and value.
* `DefaultS3EventNotificationWriter`: emits `awsGeneratedTags` only
when the map is non-null and non-empty, matching S3's server-side
`@JsonInclude(NON_EMPTY)` behavior so round-tripped output is
indistinguishable from what S3 emits.
Also bumps `eventVersion` fixtures in the module test files from
`2.4` to `2.5` to reflect the schema version emitted alongside this
launch.
The change is fully additive:
* Older SDKs remain compatible with new payloads (unknown fields
are ignored during parse).
* Newer SDKs remain compatible with old payloads
(`getAwsGeneratedTags()` returns `null` when the field is absent).
ee45a15 to
0b1c256
Compare
alextwoods
approved these changes
Jul 14, 2026
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.
Motivation and Context
Amazon S3 event notifications delivered to SNS, SQS, and Lambda will include a new
awsGeneratedTagsmap on thebucketobject when system tags are enabled on the source bucket. The Java SDK model did not round-trip this field, so consumers had to fall back to raw JSON parsing to read the tags. This PR adds first-class support for the field on both the reader and writer sides.Related: SIM P459766202 (internal launch coordination).
Note to reviewers: This PR targets
masterfor review only. The intent is to retarget to a feature branch once the AWS Java SDK team creates one, and merge on launch day (7/15/2026).Modifications
S3Bucket: new Map<String, String> awsGeneratedTags field with getter, a new four-argument constructor, and updates to equals/hashCode/toString. The pre-existing three-argument constructor is preserved so existing callers are source- and behavior-compatible. Tags are defensively copied on construction and returned as an unmodifiable view..DefaultS3EventNotificationReader: parsesawsGeneratedTagsasMap<String, String>using aLinkedHashMap(preserves S3 emission order). Absent field yieldsnull. Null value entries are preserved. Non-string values throwIllegalArgumentExceptionwith a helpful message including the offending key and value.DefaultS3EventNotificationWriter: emitsawsGeneratedTagsonly when the map is non-null and non-empty, matching S3 server-side@JsonInclude(NON_EMPTY)behavior so round-tripped output is indistinguishable from what S3 emits.eventVersionfixtures in the module test files from2.4to2.5to reflect the schema version emitted alongside this launch.Testing
Added tests in three files:
S3BucketTest(new): S3BucketTest (new): 3-arg and 4-arg constructor defaults, toString behavior (omit-when-null, include-when-present with key/value assertions across multiple tags), defensive-copy of the tag map, and unmodifiable view via the getter.S3EventNotificationReaderTest: parse when present, absent, empty; null value preserved; empty string preserved; non-string value throws; boolean value throws; non-object throws.S3EventNotificationWriterTest: written when set (with round-trip); omitted when null; omitted when empty; null tag value preserved (round-trip); empty-string tag value preserved (round-trip).Local run of
./mvnw test -pl :s3-event-notificationspasses with 39 tests, 0 failures.Screenshots (if appropriate)
N/A
Types of changes
Checklist
mvn installsucceeds (module-level tests pass)scripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License