-
Notifications
You must be signed in to change notification settings - Fork 28
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
fix: Add default value handling for a scalar member of server response struct #576
Conversation
This resolves the S3:deleteObjects() issue awslabs/aws-sdk-swift#602, as well as anytime there're scalar members with default values missing from server response. Issue is resolved by properly assigning the default value ("false") to deleteMarker property of DeletedObject when it is not found in server response (not found when bucket that responds to request is non-versioned, which means it does not use a deleteMarker).
4d6c146
to
1e57e58
Compare
651bbd2
to
2b36d8b
Compare
…trait, not default value of the data type (0 / false).
…types are correctly translated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this approach looks good! Please take another look at lines 303-313 to see if we can make it more readable by taking advantage of Kotlin syntax. Also, I was wondering what the reasoning is for translating "null" to "nil"?
.../software/amazon/smithy/swift/codegen/integration/serde/xml/MemberShapeDecodeXMLGenerator.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the tests here, since they cover several default value cases and not just the one the bug ticket flagged.
Just address the question about null defaults and @dayaffe's comments and this should be good to merge.
.../software/amazon/smithy/swift/codegen/integration/serde/xml/MemberShapeDecodeXMLGenerator.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR addresses the deserialization error where a default value is not correctly assigned to fields when they're missing from server response.
Issue #
awslabs/aws-sdk-swift#602
Description of changes
Issue #602 is resolved by properly assigning the default value (
false
in this case) to deleteMarker property (a boolean member) of DeletedObject when it is not found in S3 server response due to the responding bucket not being versioned.With this change, when the deserializer tries to decode server response to S3:deleteObjects from a non-versioned S3 bucket, in each DeletedObject, default value is correctly assigned to be
false
to delete markers.Same applies for any other scalar member in any other server response structure that has a default value, if that member is missing from the server response struct.
A test case is added along with the change, as the change did not break any existing tests.
All changes were tested by building the
smithy-swift
project, as well as generating all the services using the changed code generator and runningswift test
as well as protocol tests on theaws-sdk-swift
project.Scope
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.