-
Notifications
You must be signed in to change notification settings - Fork 947
Fix handling of UpdateBehavior.WRITE_IF_NOT_EXISTS on @DynamoDbAutoGeneratedUuid #6391
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
Closed
anasatirbasa
wants to merge
1
commit into
aws:master
from
anasatirbasa:feature/fix-handling-of-write-if-not-exists-on-dynamo-db-autogenerated-uuid-annotation
Conversation
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
@anasatirbasa
anasatirbasa
force-pushed
the
feature/fix-handling-of-write-if-not-exists-on-dynamo-db-autogenerated-uuid-annotation
branch
6 times, most recently
from
September 5, 2025 13:58
12673d2 to
a338f64
Compare
@anasatirbasa
anasatirbasa
force-pushed
the
feature/fix-handling-of-write-if-not-exists-on-dynamo-db-autogenerated-uuid-annotation
branch
from
September 5, 2025 14:02
a338f64 to
845fe14
Compare
This issue is being closed as a duplicate of Ticket #5497, which has been resolved through PR #6373.
Additional context is available in this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
Description
Fixed the behavior of the
@DynamoDbAutoGeneratedUuidannotation in combination with@DynamoDbUpdateBehavior(UpdateBehavior.WRITE_IF_NOT_EXISTS).Previously, a new UUID was generated even when the attribute already had a value. With this change:
UUID.randomUUID()).WRITE_IF_NOT_EXISTS, existing values in DynamoDB are preserved using theif_not_exists(...)expression.This ensures that UUIDs are only generated once for attributes tagged with
WRITE_IF_NOT_EXISTSand remain stable across subsequent updates.Important Note
Stringattribute.@DynamoDbAutoGeneratedKey(implementation added with this PR) , this extension does not enforce PK/SK or index-only usage — it supports non-key attributes.putItem, the entire item is always replaced, so if the field is absent, a new UUID will still be generated, even withWRITE_IF_NOT_EXISTS.Motivation and Context
#5703
This bug fix improves consistency with the documented semantics of
WRITE_IF_NOT_EXISTSand matches user expectations.Modifications
AutoGeneratedUuidExtensionto only generate UUIDs if the attribute is missing or empty.WRITE_IF_NOT_EXISTS.AutoGeneratedUuidExtensionTestand functional tests inAutoGeneratedUuidRecordTestto verify:WRITE_ALWAYSvs.WRITE_IF_NOT_EXISTS.Testing
putItemandupdateItem.Test Coverage Checklist
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License