From 199aad028afbce3daf43fcd32267c41971133a43 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:44:05 -0800 Subject: [PATCH] fix(middleware-flexible-checksums): use input from args and not middleware config (#6677) --- clients/client-s3/src/commands/DeleteObjectsCommand.ts | 1 - clients/client-s3/src/commands/GetObjectCommand.ts | 1 - .../commands/PutBucketAccelerateConfigurationCommand.ts | 1 - clients/client-s3/src/commands/PutBucketAclCommand.ts | 1 - clients/client-s3/src/commands/PutBucketCorsCommand.ts | 1 - .../client-s3/src/commands/PutBucketEncryptionCommand.ts | 1 - .../commands/PutBucketLifecycleConfigurationCommand.ts | 1 - clients/client-s3/src/commands/PutBucketLoggingCommand.ts | 1 - .../src/commands/PutBucketOwnershipControlsCommand.ts | 1 - clients/client-s3/src/commands/PutBucketPolicyCommand.ts | 1 - .../client-s3/src/commands/PutBucketReplicationCommand.ts | 1 - .../src/commands/PutBucketRequestPaymentCommand.ts | 1 - clients/client-s3/src/commands/PutBucketTaggingCommand.ts | 1 - .../client-s3/src/commands/PutBucketVersioningCommand.ts | 1 - clients/client-s3/src/commands/PutBucketWebsiteCommand.ts | 1 - clients/client-s3/src/commands/PutObjectAclCommand.ts | 1 - clients/client-s3/src/commands/PutObjectCommand.ts | 1 - .../client-s3/src/commands/PutObjectLegalHoldCommand.ts | 1 - .../src/commands/PutObjectLockConfigurationCommand.ts | 1 - .../client-s3/src/commands/PutObjectRetentionCommand.ts | 1 - clients/client-s3/src/commands/PutObjectTaggingCommand.ts | 1 - .../client-s3/src/commands/PutPublicAccessBlockCommand.ts | 1 - clients/client-s3/src/commands/RestoreObjectCommand.ts | 1 - clients/client-s3/src/commands/UploadPartCommand.ts | 1 - .../aws/typescript/codegen/AddHttpChecksumDependency.java | 2 -- .../src/flexibleChecksumsMiddleware.spec.ts | 4 ++-- .../src/flexibleChecksumsMiddleware.ts | 8 ++------ 27 files changed, 4 insertions(+), 34 deletions(-) diff --git a/clients/client-s3/src/commands/DeleteObjectsCommand.ts b/clients/client-s3/src/commands/DeleteObjectsCommand.ts index 57727ddec80d..09378b0aaa82 100644 --- a/clients/client-s3/src/commands/DeleteObjectsCommand.ts +++ b/clients/client-s3/src/commands/DeleteObjectsCommand.ts @@ -307,7 +307,6 @@ export class DeleteObjectsCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/GetObjectCommand.ts b/clients/client-s3/src/commands/GetObjectCommand.ts index 3af214d29fc6..154538a85f1a 100644 --- a/clients/client-s3/src/commands/GetObjectCommand.ts +++ b/clients/client-s3/src/commands/GetObjectCommand.ts @@ -360,7 +360,6 @@ export class GetObjectCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestChecksumRequired: false, requestValidationModeMember: "ChecksumMode", responseAlgorithms: ["CRC32", "CRC32C", "SHA256", "SHA1"], diff --git a/clients/client-s3/src/commands/PutBucketAccelerateConfigurationCommand.ts b/clients/client-s3/src/commands/PutBucketAccelerateConfigurationCommand.ts index 6be66e3545fe..0a3945af0266 100644 --- a/clients/client-s3/src/commands/PutBucketAccelerateConfigurationCommand.ts +++ b/clients/client-s3/src/commands/PutBucketAccelerateConfigurationCommand.ts @@ -123,7 +123,6 @@ export class PutBucketAccelerateConfigurationCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: false, }), diff --git a/clients/client-s3/src/commands/PutBucketAclCommand.ts b/clients/client-s3/src/commands/PutBucketAclCommand.ts index a19c526d1461..b1963d325ae6 100644 --- a/clients/client-s3/src/commands/PutBucketAclCommand.ts +++ b/clients/client-s3/src/commands/PutBucketAclCommand.ts @@ -314,7 +314,6 @@ export class PutBucketAclCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutBucketCorsCommand.ts b/clients/client-s3/src/commands/PutBucketCorsCommand.ts index eff76383c463..55c4c5d33fe9 100644 --- a/clients/client-s3/src/commands/PutBucketCorsCommand.ts +++ b/clients/client-s3/src/commands/PutBucketCorsCommand.ts @@ -198,7 +198,6 @@ export class PutBucketCorsCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutBucketEncryptionCommand.ts b/clients/client-s3/src/commands/PutBucketEncryptionCommand.ts index 62f5fcb6295d..4d08df19335f 100644 --- a/clients/client-s3/src/commands/PutBucketEncryptionCommand.ts +++ b/clients/client-s3/src/commands/PutBucketEncryptionCommand.ts @@ -198,7 +198,6 @@ export class PutBucketEncryptionCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutBucketLifecycleConfigurationCommand.ts b/clients/client-s3/src/commands/PutBucketLifecycleConfigurationCommand.ts index 12cf74649215..9dd8deb0a1dc 100644 --- a/clients/client-s3/src/commands/PutBucketLifecycleConfigurationCommand.ts +++ b/clients/client-s3/src/commands/PutBucketLifecycleConfigurationCommand.ts @@ -260,7 +260,6 @@ export class PutBucketLifecycleConfigurationCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutBucketLoggingCommand.ts b/clients/client-s3/src/commands/PutBucketLoggingCommand.ts index 4efecf7ecadb..6c825b4adaa8 100644 --- a/clients/client-s3/src/commands/PutBucketLoggingCommand.ts +++ b/clients/client-s3/src/commands/PutBucketLoggingCommand.ts @@ -214,7 +214,6 @@ export class PutBucketLoggingCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutBucketOwnershipControlsCommand.ts b/clients/client-s3/src/commands/PutBucketOwnershipControlsCommand.ts index f9d3c1c96f84..65fec824b489 100644 --- a/clients/client-s3/src/commands/PutBucketOwnershipControlsCommand.ts +++ b/clients/client-s3/src/commands/PutBucketOwnershipControlsCommand.ts @@ -104,7 +104,6 @@ export class PutBucketOwnershipControlsCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestChecksumRequired: true, }), ]; diff --git a/clients/client-s3/src/commands/PutBucketPolicyCommand.ts b/clients/client-s3/src/commands/PutBucketPolicyCommand.ts index 18f341a27992..ddf473bb2ff0 100644 --- a/clients/client-s3/src/commands/PutBucketPolicyCommand.ts +++ b/clients/client-s3/src/commands/PutBucketPolicyCommand.ts @@ -157,7 +157,6 @@ export class PutBucketPolicyCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutBucketReplicationCommand.ts b/clients/client-s3/src/commands/PutBucketReplicationCommand.ts index 641379180e0f..f5023f652783 100644 --- a/clients/client-s3/src/commands/PutBucketReplicationCommand.ts +++ b/clients/client-s3/src/commands/PutBucketReplicationCommand.ts @@ -239,7 +239,6 @@ export class PutBucketReplicationCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutBucketRequestPaymentCommand.ts b/clients/client-s3/src/commands/PutBucketRequestPaymentCommand.ts index 8cde3add1e7e..40b02d7774fe 100644 --- a/clients/client-s3/src/commands/PutBucketRequestPaymentCommand.ts +++ b/clients/client-s3/src/commands/PutBucketRequestPaymentCommand.ts @@ -114,7 +114,6 @@ export class PutBucketRequestPaymentCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutBucketTaggingCommand.ts b/clients/client-s3/src/commands/PutBucketTaggingCommand.ts index 35c320c62eb8..94a3a4d44075 100644 --- a/clients/client-s3/src/commands/PutBucketTaggingCommand.ts +++ b/clients/client-s3/src/commands/PutBucketTaggingCommand.ts @@ -168,7 +168,6 @@ export class PutBucketTaggingCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutBucketVersioningCommand.ts b/clients/client-s3/src/commands/PutBucketVersioningCommand.ts index 4b242e4860f7..34f8d2734a3c 100644 --- a/clients/client-s3/src/commands/PutBucketVersioningCommand.ts +++ b/clients/client-s3/src/commands/PutBucketVersioningCommand.ts @@ -149,7 +149,6 @@ export class PutBucketVersioningCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutBucketWebsiteCommand.ts b/clients/client-s3/src/commands/PutBucketWebsiteCommand.ts index 495a23513fe2..6f2a528dfee8 100644 --- a/clients/client-s3/src/commands/PutBucketWebsiteCommand.ts +++ b/clients/client-s3/src/commands/PutBucketWebsiteCommand.ts @@ -249,7 +249,6 @@ export class PutBucketWebsiteCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutObjectAclCommand.ts b/clients/client-s3/src/commands/PutObjectAclCommand.ts index ab7017a2e28c..4724ddaa77c3 100644 --- a/clients/client-s3/src/commands/PutObjectAclCommand.ts +++ b/clients/client-s3/src/commands/PutObjectAclCommand.ts @@ -313,7 +313,6 @@ export class PutObjectAclCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutObjectCommand.ts b/clients/client-s3/src/commands/PutObjectCommand.ts index b9978cd24f94..a818ed1a0cb3 100644 --- a/clients/client-s3/src/commands/PutObjectCommand.ts +++ b/clients/client-s3/src/commands/PutObjectCommand.ts @@ -413,7 +413,6 @@ export class PutObjectCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: false, }), diff --git a/clients/client-s3/src/commands/PutObjectLegalHoldCommand.ts b/clients/client-s3/src/commands/PutObjectLegalHoldCommand.ts index 4439d9908630..278ef5292dc7 100644 --- a/clients/client-s3/src/commands/PutObjectLegalHoldCommand.ts +++ b/clients/client-s3/src/commands/PutObjectLegalHoldCommand.ts @@ -91,7 +91,6 @@ export class PutObjectLegalHoldCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutObjectLockConfigurationCommand.ts b/clients/client-s3/src/commands/PutObjectLockConfigurationCommand.ts index 7041958683bb..8b99cda53a4c 100644 --- a/clients/client-s3/src/commands/PutObjectLockConfigurationCommand.ts +++ b/clients/client-s3/src/commands/PutObjectLockConfigurationCommand.ts @@ -114,7 +114,6 @@ export class PutObjectLockConfigurationCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutObjectRetentionCommand.ts b/clients/client-s3/src/commands/PutObjectRetentionCommand.ts index 74c56d0a12a5..587834590e1a 100644 --- a/clients/client-s3/src/commands/PutObjectRetentionCommand.ts +++ b/clients/client-s3/src/commands/PutObjectRetentionCommand.ts @@ -94,7 +94,6 @@ export class PutObjectRetentionCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutObjectTaggingCommand.ts b/clients/client-s3/src/commands/PutObjectTaggingCommand.ts index 06510a97f709..f6f48c3d17c8 100644 --- a/clients/client-s3/src/commands/PutObjectTaggingCommand.ts +++ b/clients/client-s3/src/commands/PutObjectTaggingCommand.ts @@ -174,7 +174,6 @@ export class PutObjectTaggingCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/PutPublicAccessBlockCommand.ts b/clients/client-s3/src/commands/PutPublicAccessBlockCommand.ts index 4306cf2cbe5f..b3ab5faf036f 100644 --- a/clients/client-s3/src/commands/PutPublicAccessBlockCommand.ts +++ b/clients/client-s3/src/commands/PutPublicAccessBlockCommand.ts @@ -122,7 +122,6 @@ export class PutPublicAccessBlockCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: true, }), diff --git a/clients/client-s3/src/commands/RestoreObjectCommand.ts b/clients/client-s3/src/commands/RestoreObjectCommand.ts index a63ff0f640b2..11eaff639df1 100644 --- a/clients/client-s3/src/commands/RestoreObjectCommand.ts +++ b/clients/client-s3/src/commands/RestoreObjectCommand.ts @@ -388,7 +388,6 @@ export class RestoreObjectCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: false, }), diff --git a/clients/client-s3/src/commands/UploadPartCommand.ts b/clients/client-s3/src/commands/UploadPartCommand.ts index 3e029af75c2a..a842c4deb449 100644 --- a/clients/client-s3/src/commands/UploadPartCommand.ts +++ b/clients/client-s3/src/commands/UploadPartCommand.ts @@ -309,7 +309,6 @@ export class UploadPartCommand extends $Command getSerdePlugin(config, this.serialize, this.deserialize), getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getFlexibleChecksumsPlugin(config, { - input: this.input, requestAlgorithmMember: "ChecksumAlgorithm", requestChecksumRequired: false, }), diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddHttpChecksumDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddHttpChecksumDependency.java index 94eed9a133b2..ccf41e150e2e 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddHttpChecksumDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddHttpChecksumDependency.java @@ -25,7 +25,6 @@ import java.util.TreeMap; import java.util.function.Consumer; import software.amazon.smithy.aws.traits.HttpChecksumTrait; -import software.amazon.smithy.codegen.core.Symbol; import software.amazon.smithy.codegen.core.SymbolProvider; import software.amazon.smithy.model.Model; import software.amazon.smithy.model.knowledge.TopDownIndex; @@ -197,7 +196,6 @@ private static Map getPluginFunctionParams( OperationShape operation ) { Map params = new TreeMap(); - params.put("input", Symbol.builder().name("this.input").build()); HttpChecksumTrait httpChecksumTrait = operation.expectTrait(HttpChecksumTrait.class); params.put("requestChecksumRequired", httpChecksumTrait.isRequestChecksumRequired()); diff --git a/packages/middleware-flexible-checksums/src/flexibleChecksumsMiddleware.spec.ts b/packages/middleware-flexible-checksums/src/flexibleChecksumsMiddleware.spec.ts index a29583f62c35..9d284db11a2a 100644 --- a/packages/middleware-flexible-checksums/src/flexibleChecksumsMiddleware.spec.ts +++ b/packages/middleware-flexible-checksums/src/flexibleChecksumsMiddleware.spec.ts @@ -29,12 +29,12 @@ describe(flexibleChecksumsMiddleware.name, () => { const mockInput = {}; const mockConfig = {} as PreviouslyResolved; - const mockMiddlewareConfig = { input: mockInput, requestChecksumRequired: false }; + const mockMiddlewareConfig = { requestChecksumRequired: false }; const mockBody = { body: "mockRequestBody" }; const mockHeaders = { "content-length": 100, "content-encoding": "gzip" }; const mockRequest = { body: mockBody, headers: mockHeaders }; - const mockArgs = { request: mockRequest } as BuildHandlerArguments; + const mockArgs = { input: mockInput, request: mockRequest } as BuildHandlerArguments; const mockResult = { response: { body: "mockResponsebody" } }; beforeEach(() => { diff --git a/packages/middleware-flexible-checksums/src/flexibleChecksumsMiddleware.ts b/packages/middleware-flexible-checksums/src/flexibleChecksumsMiddleware.ts index cc5efb32212a..317537dd9ab7 100644 --- a/packages/middleware-flexible-checksums/src/flexibleChecksumsMiddleware.ts +++ b/packages/middleware-flexible-checksums/src/flexibleChecksumsMiddleware.ts @@ -21,10 +21,6 @@ import { stringHasher } from "./stringHasher"; export interface FlexibleChecksumsRequestMiddlewareConfig { /** - * The input object for the operation. - */ - input: Object; - /** * Indicates an operation requires a checksum in its HTTP request. */ @@ -57,10 +53,10 @@ export const flexibleChecksumsMiddleware = return next(args); } - const { request } = args; + const { request, input } = args; const { body: requestBody, headers } = request; const { base64Encoder, streamHasher } = config; - const { input, requestChecksumRequired, requestAlgorithmMember } = middlewareConfig; + const { requestChecksumRequired, requestAlgorithmMember } = middlewareConfig; const checksumAlgorithm = getChecksumAlgorithmForRequest( input,