Skip to content

Conversation

@lauzadis
Copy link
Contributor

Issue #

Description of changes

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

@github-actions

This comment has been minimized.

@github-actions
Copy link

Affected Artifacts

No artifacts changed size

@lauzadis lauzadis marked this pull request as ready for review November 14, 2024 17:33
@lauzadis lauzadis requested a review from a team as a code owner November 14, 2024 17:33
Comment on lines -142 to +147
writer.write("builder.headers.setMissing(\"Content-Type\", #S)", resolver.determineRequestContentType(op))
val contentTypeHeader = when {
op.isInputEventStream(ctx.model) -> "application/vnd.amazon.eventstream"
else -> "application/cbor"
}

writer.write("builder.headers.setMissing(\"Content-Type\", #S)", contentTypeHeader)
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: I don't see how this code materially differs from what we had before in determineRequestContentType. How does this fix the bug of incorrectly setting the content type for event stream inputs?

Copy link
Contributor Author

@lauzadis lauzadis Nov 14, 2024

Choose a reason for hiding this comment

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

The error we had before was in setting the :content-type during event stream message serialization. The value of that content type is set by determineRequestContentType which now only returns application/cbor.

However the overall request Content-Type still needs to be application/vnd.amazon.eventstream for event streams, which is what this renderContentTypeHeader function does

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the tests I wrote do a good job explaining the requirements but let me know if there's clarification to be done

Comment on lines +46 to +48
// Model taken from https://smithy.io/2.0/spec/streaming.html#event-streams
@streaming
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Is this comment still accurate given the additional shapes we've added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, PublishEvents / Message / LeaveEvent are in that Smithy docs page

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think the comment is a little unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I disagree, more context is better than less

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fair


// Event stream requests should have Content-Type=application/vnd.amazon.eventstream
val serializeBody = serializer.lines(" override suspend fun serialize(context: ExecutionContext, input: PutFooStreamingRequest): HttpRequestBuilder {", "}")
serializeBody.shouldContainOnlyOnceWithDiff("""builder.headers.setMissing("Content-Type", "application/vnd.amazon.eventstream")""")
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: This is coming from line 252 of HttpBindingProtocolGenerator.kt right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

if (op.isInputEventStream(ctx.model)) {
val eventStreamSerializeFn = eventStreamRequestHandler(ctx, op)
writer.write("builder.body = #T(context, input)", eventStreamSerializeFn)
renderContentTypeHeader(ctx, op, writer, resolver)
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: This doesn't break anything for the other protocols?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not that I've seen. we have e2e tests for event streams in aws-sdk-kotlin

Comment on lines +46 to +48
// Model taken from https://smithy.io/2.0/spec/streaming.html#event-streams
@streaming
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think the comment is a little unnecessary

@lauzadis lauzadis merged commit b3ab799 into main Nov 14, 2024
16 checks passed
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