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

Upgrade Smithy to 1.50.0 #3728

Merged
merged 9 commits into from
Jul 5, 2024
Merged

Upgrade Smithy to 1.50.0 #3728

merged 9 commits into from
Jul 5, 2024

Conversation

ysaito1001
Copy link
Contributor

@ysaito1001 ysaito1001 commented Jun 28, 2024

Motivation and Context

This PR upgrades Smithy to 1.50.0. The majority of the changes follow TODO added in #3690. Other than that, a few adjustments needed to be made:

  • for the client
    • added two failing tests RestJsonClientPopulatesDefaultValuesInInput and RestJsonClientUsesExplicitlyProvidedMemberValuesOverDefaults to known failing tests for the same reason here
    • added one broken test (i.e. the upstream test definition is incorrect but our implementation is correct) to known broken tests per (smithy#2341, smithy-rs#3726)
  • for the server
    • removed rest-xml-extras.smithy since RestXmlMustSupportParametersInContentType is now available upstream Smithy 1.50.0
    • added the following to known failing tests (since the awsJson1_0 counterparts are already in the list, but we need the server team to verify this assumption & provide additional TODO comments if necessary)
      • RestJsonServerPopulatesDefaultsWhenMissingInRequestBody
      • RestJsonServerPopulatesDefaultsInResponseWhenMissingInParams,
      • RestJsonServerPopulatesNestedDefaultValuesWhenMissingInInResponseParams

Testing

Existing tests in CI


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ysaito1001 ysaito1001 closed this Jun 28, 2024
@ysaito1001 ysaito1001 reopened this Jun 28, 2024
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

This commit disables the said tests, assuming that the reason for
failures is the same as those disabled for AwsJson1_0. Should
verify with the server team.
Copy link

github-actions bot commented Jul 1, 2024

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link

github-actions bot commented Jul 1, 2024

A new generated diff is ready to view.

A new doc preview is ready to view.

@ysaito1001 ysaito1001 marked this pull request as ready for review July 1, 2024 22:29
@ysaito1001 ysaito1001 requested review from a team as code owners July 1, 2024 22:29
@@ -141,12 +138,15 @@ class ServerProtocolTestGenerator(
// These tests are broken because they are missing a target header.
FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ServerPopulatesNestedDefaultsWhenMissingInRequestBody"),
FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ServerPopulatesDefaultsWhenMissingInRequestBody"),
FailingTest.RequestTest(REST_JSON, "RestJsonServerPopulatesDefaultsWhenMissingInRequestBody"),
Copy link
Contributor

Choose a reason for hiding this comment

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

RestJsonServerPopulatesDefaultsWhenMissingInRequestBody fails because defaultNullDocument has a null default, so the hasNonNullDefault check here:

is false and so aws_smithy_types::Document::Null is not used by the instantiator.

But even if we improved the check and special-cased document member shapes, there's an additional problem: the same check is used by Smithy itself here when determining whether the structure member should be optional or not. Since the node for the @default value of the member shape is null, Smithy says the structure member should be optional. But the generated code for default value setting expects the member to be non-Optional, since there's a default value.

In general, this begs the question of whether a required (non-Optional) document shape makes sense at all. The user can always set it to aws_smithy_types::Document::Null and convey the same semantics as if shape were nullable and None had been set for it. To belabor the point, consider this model:

structure OperationInput {
    @required
    document: Document
}

This gets generated in Rust as:

struct OperationInput {
    document: aws_smithy_types::Document
}

The user can instantiate this as:

let op_input = OperationInput::builder()
    .document(aws_smithy_types::Document::Null)
    .build();

Which will get serialized on the wire as { document: null } or { }, depending on whether the protocol serializes nulls or not, respectively. Either way, we're allowing the user to not provide a value for a required member shape, violating the model.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the detailed explanation! Moved the test to the bottom of the list and added a link to this discussion for more context.

Copy link

github-actions bot commented Jul 2, 2024

A new generated diff is ready to view.

A new doc preview is ready to view.

This commit adds a link to a discussion:
#3728 (comment)

on why the test fails and the test itself might be questionable
Copy link

github-actions bot commented Jul 2, 2024

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link

github-actions bot commented Jul 3, 2024

A new generated diff is ready to view.

A new doc preview is ready to view.

@ysaito1001 ysaito1001 enabled auto-merge July 5, 2024 13:48
Copy link

github-actions bot commented Jul 5, 2024

A new generated diff is ready to view.

A new doc preview is ready to view.

@ysaito1001 ysaito1001 added this pull request to the merge queue Jul 5, 2024
Merged via the queue into main with commit 17545f6 Jul 5, 2024
44 checks passed
@ysaito1001 ysaito1001 deleted the ysaito/upgrade-smithy-1-50-0 branch July 5, 2024 15:26
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.

3 participants