Skip to content

Commit b9300aa

Browse files
committed
Fix issue filling idempotency tokens
1 parent f2fab73 commit b9300aa

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Diff for: smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ public Void objectNode(ObjectNode node) {
515515
}
516516

517517
// Handle auto-filling idempotency token values to the explicit value.
518-
if (memberShape.hasTrait(IdempotencyTokenTrait.class)) {
518+
if (isIdempotencyTokenWithoutValue(memberShape, valueNode)) {
519519
writer.write("\"00000000-0000-4000-8000-000000000000\",");
520520
} else {
521521
this.workingShape = model.expectShape(memberShape.getTarget());
@@ -525,7 +525,6 @@ public Void objectNode(ObjectNode node) {
525525
});
526526
// Check for setting a potentially unspecified member value for the
527527
// idempotency token.
528-
// TODO Move a check to validation instead of filling here?
529528
if (node.getMembers().isEmpty() && wrapperShape.isStructureShape()) {
530529
StructureShape structureShape = wrapperShape.asStructureShape().get();
531530
for (Map.Entry<String, MemberShape> entry : structureShape.getAllMembers().entrySet()) {
@@ -539,6 +538,16 @@ public Void objectNode(ObjectNode node) {
539538
return null;
540539
}
541540

541+
private boolean isIdempotencyTokenWithoutValue(MemberShape memberShape, Node valueNode) {
542+
// Short circuit non-tokens.
543+
if (!memberShape.hasTrait(IdempotencyTokenTrait.class)) {
544+
return false;
545+
}
546+
547+
// Return if the token has a test-specific value.
548+
return valueNode.expectStringNode().getValue().isEmpty();
549+
}
550+
542551
@Override
543552
public Void stringNode(StringNode node) {
544553
// Handle blobs needing to be converted from strings to their input type of UInt8Array.

0 commit comments

Comments
 (0)