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: skip streaming data for union check in readPayload #1426

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2452,8 +2452,10 @@ private HttpBinding readPayload(
// There can only be one payload binding.
Shape target = context.getModel().expectShape(binding.getMember().getTarget());

boolean isStreaming = target.hasTrait(StreamingTrait.class);

// Handle streaming shapes differently.
if (target.hasTrait(StreamingTrait.class)) {
if (isStreaming) {
writer.write("const data: any = output.body;");
// If payload is streaming blob, return low-level stream with the stream utility functions mixin.
if (isClientSdk && target instanceof BlobShape) {
Expand All @@ -2479,7 +2481,7 @@ private HttpBinding readPayload(
target.getType()));
}

if (target instanceof UnionShape) {
if (!isStreaming && target instanceof UnionShape) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is to match the condition on line 2472

} else if (target instanceof UnionShape) {

which isn't only target instanceof UnionShape but also that the prior if branch was not entered.

writer.openBlock(
"if (Object.keys(data ?? {}).length) {",
"}",
Expand Down
Loading