Skip to content

Commit

Permalink
fix: skip streaming data for union check in readPayload (#1426)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored Oct 4, 2024
1 parent e8b99b1 commit 5c4370a
Showing 1 changed file with 4 additions and 2 deletions.
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) {
writer.openBlock(
"if (Object.keys(data ?? {}).length) {",
"}",
Expand Down

0 comments on commit 5c4370a

Please sign in to comment.