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.16.1 #1053

Merged
merged 11 commits into from
Jan 12, 2022
Merged

Upgrade Smithy to 1.16.1 #1053

merged 11 commits into from
Jan 12, 2022

Conversation

jdisanti
Copy link
Collaborator

@jdisanti jdisanti commented Jan 8, 2022

Description

This PR upgrades Smithy from 1.13 to 1.16.1.

Smithy change log here: https://github.com/awslabs/smithy/blob/main/CHANGELOG.md

Biggest changes:

  • Entries in string list headers can now be quoted so that they can contain commas and escaped quotation marks
  • The AWS JSON protocols no longer support @jsonName

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates

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

@jdisanti jdisanti requested review from a team as code owners January 8, 2022 02:49
@github-actions
Copy link

github-actions bot commented Jan 8, 2022

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Jan 8, 2022

A new generated diff is ready to view.

@github-actions
Copy link

github-actions bot commented Jan 8, 2022

A new generated diff is ready to view.

@github-actions
Copy link

github-actions bot commented Jan 8, 2022

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Jan 8, 2022

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Jan 8, 2022

A new generated diff is ready to view.

@github-actions
Copy link

github-actions bot commented Jan 8, 2022

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Jan 8, 2022

A new generated diff is ready to view.

Copy link
Collaborator

@rcoh rcoh left a comment

Choose a reason for hiding this comment

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

Overall looks great! I think we may need more tests on the quoted header parsing

@github-actions
Copy link

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

@github-actions
Copy link

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

@david-perez
Copy link
Contributor

There are 5 protocol test failures for the server.

  1. 2 of them are for missing required header: <header> (example).
  2. 3 of them are for RequestExtensions not found (example).

The 5 tests are new in Smithy 1.16 and are not regressions i.e. had they been in the current Smithy version we're using, the server would still have failed. The server is doing poorly at protocol tests; I'm working on reducing the failures.

(1) is due to us not generating the tests correctly, we're not inserting the input headers to construct the request. Adding them should make many more tests pass.

(2) is due to us only inserting RequestExtensions in responses for fallible operations (link). We should add them to all responses and rename the struct to ResponseExtensions, since we're adding them only to responses.

I've created GitHub issues to track these and I will be tackling them shortly:

  1. Add input headers to requests in server protocol compliance tests #1062
  2. Add ResponseExtensions to _all_ server responses #1063

Since these fixes are semantically unrelated to this PR, I suggest I fix them in separate PRs. To unblock merging this PR, you can add this patch:

diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt
index aad4fdc1..0afb1004 100644
--- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt
+++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt
@@ -431,6 +431,11 @@ class ServerProtocolTestGenerator(
         private val AwsQuery = "aws.protocoltests.query#AwsQuery"
         private val Ec2Query = "aws.protocoltests.ec2#AwsEc2"
         private val ExpectFail = setOf<FailingTest>(
+            FailingTest(RestJson, "RestJsonInputAndOutputWithQuotedStringHeaders", Action.Request),
+            FailingTest(RestJson, "RestJsonInputAndOutputWithQuotedStringHeaders", Action.Response),
+            FailingTest(RestJson, "RestJsonOutputUnionWithUnitMember", Action.Response),
+            FailingTest(RestJson, "RestJsonUnitInputAllowsAccept", Action.Request),
+            FailingTest(RestJson, "RestJsonUnitInputAndOutputNoOutput", Action.Response),
             FailingTest(RestJson, "RestJsonAllQueryStringTypes", Action.Request),
             FailingTest(RestJson, "RestJsonQueryStringEscaping", Action.Request),
             FailingTest(RestJson, "RestJsonSupportsNaNFloatQueryValues", Action.Request),

Copy link
Collaborator

@rcoh rcoh left a comment

Choose a reason for hiding this comment

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

LGTM! might be worth fuzzing the many_dates stuff while we're there but not urgent

Comment on lines 219 to 225
if inner.contains("\\\"") {
inner = Cow::Owned(inner.replace("\\\"", "\""));
}
let rest = then_delim(&input[(index + 1)..])?;
if inner.contains("\\\\") {
inner = Cow::Owned(inner.replace("\\\\", "\\"));
}
let rest = then_comma(&input[(index + 1)..])?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

could factor out fn replace(cow, pat, pat) -> cow

Comment on lines 371 to 387
fn read_many_strings() {
let test_request = http::Request::builder()
.header("Empty", "")
.header("Foo", "foo")
.header("Foo", " foo")
.header("FooInQuotes", "\" foo\"")
.header("CommaInQuotes", "\"foo,bar\",baz")
.header("QuoteInQuotes", "\"foo\\\",bar\",\"\\\"asdf\\\"\",baz")
.header(
"QuoteInQuotesWithSpaces",
"\"foo\\\",bar\", \"\\\"asdf\\\"\", baz",
)
.header("JunkFollowingQuotes", "\"\\\"asdf\\\"\"baz")
.header("EmptyQuotes", "\"\",baz")
.header("EscapedSlashesInQuotes", "foo, \"(foo\\\\bar)\"")
.body(())
.unwrap();
let read =
Copy link
Collaborator

Choose a reason for hiding this comment

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

should probably also hit trailing whitespace


fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
if let Ok(req) = http::Request::builder().header("test", s).body(()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this ever return OK? you can make a request without a URI?

Copy link
Collaborator Author

@jdisanti jdisanti Jan 12, 2022

Choose a reason for hiding this comment

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

Yeah, the builder builds successfully. I verified by adding a panic! inside of the conditions, and it definitely gets triggered.

@@ -1,3 +1,8 @@
/*
Copy link
Collaborator

Choose a reason for hiding this comment

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

hooray for lints

Copy link
Contributor

@crisidev crisidev left a comment

Choose a reason for hiding this comment

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

Looks good from the server codegen perspective.

@jdisanti jdisanti merged commit c25c24d into main Jan 12, 2022
@jdisanti jdisanti deleted the jdisanti-upgrade-to-smithy-116 branch January 12, 2022 23:35
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.

4 participants