Skip to content
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

Merged
merged 11 commits into from
Aug 11, 2023

Conversation

sichanyoo
Copy link
Contributor

@sichanyoo sichanyoo commented Aug 9, 2023

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 running swift test as well as protocol tests on the aws-sdk-swift project.

Scope

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

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sichanyoo sichanyoo changed the title Add default value handling for a scalar member of server response struct fix: Add default value handling for a scalar member of server response struct Aug 9, 2023
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).
Copy link
Contributor

@dayaffe dayaffe left a 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"?

Copy link
Contributor

@jbelkins jbelkins left a 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.

Copy link
Contributor

@dayaffe dayaffe left a comment

Choose a reason for hiding this comment

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

LGTM

@sichanyoo sichanyoo merged commit 83826f8 into main Aug 11, 2023
7 checks passed
@sichanyoo sichanyoo deleted the fix/S3-default-val branch August 11, 2023 16:50
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.

S3 deleteObjects() throws exception in verbose mode when successful
3 participants