Skip to content

Commit 5c4370a

Browse files
authored
fix: skip streaming data for union check in readPayload (#1426)
1 parent e8b99b1 commit 5c4370a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,8 +2452,10 @@ private HttpBinding readPayload(
24522452
// There can only be one payload binding.
24532453
Shape target = context.getModel().expectShape(binding.getMember().getTarget());
24542454

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

2482-
if (target instanceof UnionShape) {
2484+
if (!isStreaming && target instanceof UnionShape) {
24832485
writer.openBlock(
24842486
"if (Object.keys(data ?? {}).length) {",
24852487
"}",

0 commit comments

Comments
 (0)