-
Notifications
You must be signed in to change notification settings - Fork 908
VersionedRecordExtension does not support 0 as a starting value #3894
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
Comments
I definitely agree the javadoc is unclear on this point as it does not specify that it must be nullable.
I do feel that this is a defect that should be addressed. If this is not considered a bug could we reclassify this as a feature request? |
I was recently bitten by this issue again. I don't think a documentation update is sufficient and instead there should be an option to enable a specific starting value (default of 0) for users to specify how to start counting their versions. I think for backwards compatibility the logic could be updated to treat I see two possible options of how it could be implemented either at the annotation level or at the extension level. For the first option (Option A) each record type could define the starting value they want to use. This would require updating each record type but would also grant clients the ability to flexibility set the starting point to whatever value they need. @DynamoDbVersionAttribute( startAt=0 ) The second option (Option B) would be specified at extension creation time to set a consistent starting point for all records. VersionedRecordExtension.builder()
.startAt(0)
.build(); What would be concerns around Option 1 of changing the default behavior? |
@debora-ito is there a strong opposition to this approach of supporting a |
…599c1f739 Pull request: release <- staging/9efb3f9b-8285-4841-afe5-794599c1f739
Describe the bug
The VersionedRecordExtension says it will increment a version and verify that the version in DynamoDB is equal to the previous value when updating. However, the documentation is unclear that the starting value must be
null
and cannot be0
which would be a reasonable starting version. Using a value of0
results in the conditional check failing when attempting to put the item.Expected Behavior
I would expect the extension to treat
0
the same asnull
acting as a clear starting point for the versioning. This would result in an update expression where the version attribute is checked not to exist before updating.Current Behavior
The DynamoDB client throws a ConditionalUpdateFailedException because the the version field does not exist in the record.
Reproduction Steps
A simple test case modified from the SDK:
Possible Solution
Update the check in
beforeWrite
for the VersionedRecordExtension to include a check for0
.If there is concern that this may break backwards compatibility it could be added behind a feature flag in the extension itself.
Additional Information/Context
No response
AWS Java SDK version used
2.20.43
JDK version used
openjdk version "1.8.0_362"
Operating System and version
macOS 12.6.4
The text was updated successfully, but these errors were encountered: