-
Notifications
You must be signed in to change notification settings - Fork 974
Ddb versioned record extension fix #6659
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
Merged
Merged
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
Add support for handling existing records with version 0
added ability to set startAt to -1 to allow versioning to begin from 0
dagnir
reviewed
Jan 6, 2026
.changes/next-release/bugfix-DynamoDBEnhancedClient-191a1f8.json
Outdated
Show resolved
Hide resolved
alextwoods
reviewed
Jan 6, 2026
.../test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/VersionedRecordTest.java
Outdated
Show resolved
Hide resolved
.../test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/VersionedRecordTest.java
Show resolved
Hide resolved
alextwoods
reviewed
Jan 7, 2026
.changes/next-release/bugfix-DynamoDBEnhancedClient-191a1f8.json
Outdated
Show resolved
Hide resolved
alextwoods
approved these changes
Jan 7, 2026
|
dagnir
approved these changes
Jan 9, 2026
|
This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
no-api-surface-area-change
Indicate there is no API surface area change and thus API surface area review is not required
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.



Fixes: #6435
Background
In July 2024, PR #6019 introduced custom versioning support for VersionedRecordExtension, allowing developers to configure startAt and incrementBy values. However, it left two critical gaps: (1) SDK v1 → v2 migration was blocked for tables containing records with version=0, as the SDK threw
ConditionalCheckFailedExceptionwhen updating these records, and (2) new records still couldn't start at version 0, they always started at startAt + incrementBy (e.g., default config produced version 1, not 0). This PR addresses both issues.The bugs and the fixes
Issue 1: v1 Existing Records with version 0 can't be updated
Users migrating from v1 to v2 cannot update existing records that were created with version=0. v1 allowed records with version=0, but when these records are retrieved via v2's GetItem and then updated via UpdateItem, the operation fails with
ConditionalCheckFailedException. This occurs because the SDK cannot distinguish between:• A new record where the user explicitly set a certain version (was covered)
• An existing record retrieved from DynamoDB that happens to have that same version (was not covered)
Solution:
Since the client code cannot distinguish between these two states, a way we can disambiguate this is by pushing the logic to the DDB server with an OR condition:
How it works:
• New records: attribute_not_exists(version) → TRUE, operation succeeds
• Existing records: version = startAt → TRUE, operation succeeds
Issue 2: New Records Cannot Start at 0
Even after PR #6019 introduced custom versioning configuration, new records still cannot start at version 0. With the default configuration (startAt=0, incrementBy=1), the first version assigned to a new record is 1, not 0. This is because the initial version calculation uses startAt + incrementBy, meaning startAt doesn't actually control where versions begin—it's an offset that gets added to incrementBy.
Solution:
Remove validation blocking negative startAt values. This allows users to set startAt=-1, which produces the desired result:
• First version: -1 + 1 = 0
• Subsequent versions: 1, 2, 3...