@aws-sdk/s3-presigned-post: generated policy contains duplicate fields, making it longer than necessary #5153
Closed
3 tasks done
Labels
bug
This issue is a bug.
p2
This is a standard priority issue
pending-release
This issue will be fixed by an approved PR that hasn't been released yet.
response-requested
Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
Checkboxes for prior research
Describe the bug
The examples on the NPM page (https://www.npmjs.com/package/@aws-sdk/s3-presigned-post) generates a policy that is longer than necessary.
Here's the code:
The
fields
that are generated are:If you decode the
Policy
you get:It is not expected that there are duplicate conditions here (
acl
,bucket
, andstarts-with
). This makes the policy longer than necessary and wastes bandwidth.SDK version number
@aws-sdk/[email protected]
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.5.1
Reproduction Steps
I made a code sandbox with the code above which reproduces the bug: https://codesandbox.io/p/sandbox/aws-sdk-s3-presigned-post-bug-jd8rrj?file=/index.js
Observed Behavior
There are duplicate conditions in the policy which makes it longer than necessary. This wastes bandwidth and confuses developers.
This is happening because conditions are automatically added based on things other than the conditions you give it. The package is trying to be smart.
Expected Behavior
There should not be any duplicate fields.
Possible Solution
Add something that dedupes this
conditions
array:aws-sdk-js-v3/packages/s3-presigned-post/src/createPresignedPost.ts
Lines 69 to 75 in d90ba9f
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: