-
Notifications
You must be signed in to change notification settings - Fork 557
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
fix(middleware-sdk-s3): improve error message on stream upload #3571
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide the rationale why we don't fail the request but log a warning message for future reference?
Do you think the conditions are concrete enough to throw an Error? I wasn't sure if there is a possibility of something matching the conditions but still being acceptable in a PutObject request. |
from discussion: check for content length only at this middleware stage. Throw error instead of only warning. Should be safe to assume the request will fail if it reaches this step without having determined the content length. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original server-side error is actually complaining of missing Content-Length
header. So instead of validating the input type, we should validate the header.
SDK will calculate the content length injected the Content-Length
header in content length middleware. In this case, the SDK can still populate the content length if the input is stream and from the file system, hense the API request can succeed.
Regarding whether we should log warning or fail-fast, I think we can keep warning instead of throw. Because in browser, browser may populate the content-length header on behalf of users in some cases: Content-Length is a forbidden header by browser. So fail-fast for customer may block some cases where SDK cannot calculate the content length but brower can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve again!
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. |
Issue
#1920
#2348
Description
Testing
Unit tests added. Manual client testing in a linked workspace.