Skip to content

Add awsGeneratedTags field to S3Bucket in s3-event-notifications#7138

Merged
alextwoods merged 1 commit into
aws:masterfrom
ylyu-eng:feature/en-bucket-system-tags
Jul 14, 2026
Merged

Add awsGeneratedTags field to S3Bucket in s3-event-notifications#7138
alextwoods merged 1 commit into
aws:masterfrom
ylyu-eng:feature/en-bucket-system-tags

Conversation

@ylyu-eng

@ylyu-eng ylyu-eng commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

Amazon S3 event notifications delivered to SNS, SQS, and Lambda will include a new 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 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 master for 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: parses awsGeneratedTags as Map<String, String> using a LinkedHashMap (preserves S3 emission order). 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 server-side @JsonInclude(NON_EMPTY) behavior so round-tripped output is indistinguishable from what S3 emits.
  • Bumps eventVersion fixtures in the module test files from 2.4 to 2.5 to 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-notifications passes with 39 tests, 0 failures.

Screenshots (if appropriate)

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds (module-level tests pass)
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.

License

  • I confirm that this pull request can be released under the Apache 2 license

@alextwoods alextwoods mentioned this pull request Jul 13, 2026

@alextwoods alextwoods left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall looking good!

This also needs a change log - you can create one with ./scripts/new-change

@ylyu-eng ylyu-eng force-pushed the feature/en-bucket-system-tags branch 4 times, most recently from e22d9fb to ee45a15 Compare July 13, 2026 22:29
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).
@ylyu-eng ylyu-eng force-pushed the feature/en-bucket-system-tags branch from ee45a15 to 0b1c256 Compare July 14, 2026 18:00
@alextwoods alextwoods marked this pull request as ready for review July 14, 2026 22:04
@alextwoods alextwoods requested a review from a team as a code owner July 14, 2026 22:04
@alextwoods alextwoods merged commit 08c8f6d into aws:master Jul 14, 2026
23 of 26 checks passed
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

Successfully merging this pull request may close these issues.

2 participants