Closed PChol22 closed 9 months ago
After some investigation, seems like the usage of next({ ...args })
might be the reason of the issue in files packages/middleware-sdk-s3/src/check-content-length-header.ts
and
packages/middleware-sdk-s3/src/validate-bucket-name.ts
The async args => {}
part of the middleware has type HandlerArguments e.g. https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-smithy-types/Interface/InitializeHandlerArguments/.
It does not say args
is the type of the input command, only that args.input
is the type of the Command's input.
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.
Checkboxes for prior research
Describe the bug
When adding a
"initialize"
middleware to aS3Client
instance, commands intercepted by the middleware are instances ofobject
, instead of being instances of the original command.This is problematic when implementing a cache middleware: 2 different commands (ex:
GetPublicAccessBlockCommand
andGetBucketLifecycleConfigurationCommand
) with the same input (ex:{ BucketName: 'abc' }
) will be interpreted as the same command when hashed, and one of them will return incoherent data.This problem doesn't happen in other clients like LambdaClient for example.
SDK version number
@aws-sdk/client-s3@3.474.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v18.16.1
Reproduction Steps
Observed Behavior
In the middleware, args is an instance of
object
, instead of being an instance ofGetBucketLifecycleConfigurationCommand
.This broken behaviour happens with every S3Client command I tried, but doesn't happen for any other client (Lambda, EventBridge...)
Expected Behavior
Existing behaviour with clients like LambdaClient:
Args of the middleware are an instance of the command that was intercepted
Possible Solution
Dirty temporary workaround for those who are stuck:
Add an extra
commandName
parameter to the input of commands sent to the S3Client, that helps the middleware know what command it is interceptingAdditional Information/Context
No response