From 5c4370ae7df25b219c1facb6203ead15b9334d12 Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 4 Oct 2024 14:34:44 -0400 Subject: [PATCH] fix: skip streaming data for union check in readPayload (#1426) --- .../codegen/integration/HttpBindingProtocolGenerator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java index a1a2e9e7cb1..1bb7046af31 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java @@ -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) { @@ -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) {", "}",