Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate put object content length #2690

Merged
merged 3 commits into from
Jun 19, 2024
Merged

Conversation

lucix-aws
Copy link
Contributor

Add specific validation for content-length presence in PutObject, see middleware docs

Closes #2683 or at least mitigates it somewhat

@lucix-aws lucix-aws requested a review from a team as a code owner June 19, 2024 14:13
})

_, err := svc.PutObject(context.Background(), cs.Input)
if cs.ExpectErr && !strings.Contains(err.Error(), errNoContentLength.Error()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] can this be compared with errors.Is or errors.As instead of doing string comparisons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah not sure what I was doing here. This is errors.Is with extra steps

"github.com/aws/smithy-go/middleware"
)

var errNoContentLength = errors.New(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice error message

@lucix-aws lucix-aws merged commit 2f18ba5 into main Jun 19, 2024
12 checks passed
@lucix-aws lucix-aws deleted the fix-putobjectcontentlength branch June 19, 2024 19:01
wty-Bryant pushed a commit that referenced this pull request Jun 19, 2024
wty-Bryant pushed a commit that referenced this pull request Jun 19, 2024
wty-Bryant added a commit that referenced this pull request Jun 19, 2024
* Revert "validate put object content length (#2690)"

This reverts commit 2f18ba5.

revert

* add changelog

---------

Co-authored-by: Tianyi Wang <wty@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

non-io.Seeker body in streaming-blob operation causes content-length to not be set, resulting in 5xx
3 participants