-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Passing multipart data as a Buffer corrupts req.body and increase x100 Mongoose time to update records #333
Comments
In the meantime I've created richardgirges/express-fileupload#291 to try getting it fixed on |
Hey @jeanbmar — thanks for finding this and sorry to hear about your serverless struggles! I took a look into your PR within If not, another potential fix I could see would be to iterate through the data coming in from Express to only pass properties that are explicitly defined as fields within Payload. We'd likely be able to do this right in the I say we wait to see what happens with your PR, and if it gets merged, then we'll be good. If not, we will make some quick moves to pair down incoming Express request bodies. What do you think? |
Perfect, thank you! |
Update - this is now fixed, and a minor version will be coming shortly. Closing the issue now! |
Thank you very much for this and for the follow-up on express-fileupload. |
This issue has been automatically locked. |
Bug Report
After 2 days of headaches wondering why it took 15s to update a single record on our serverless deployment, I figured out that
req.body
gets corrupted byexpress-fileupload
if the multipart body passed toexpress
is a Buffer instance (reasons explained here: richardgirges/express-fileupload#290).Popular serverless express proxies do this transformation, which is probably valid and properly managed by busboy anyway.
Mongoose will then receive an object containing the usual properties as well as extra properties, 1 property per byte in the req.body buffer to be accurate, and will try to validate every one of them, so you see the disaster coming.
Anyone using Payload with Serverless and AWS Lambda will have this problem.
Expected Behavior
The
req.body
object should contain only the relevant properties.Possible Solution
I doubt
express-fileupload
will be fixed anytime soon.express-fileupload
to transform any buffer into somethingexpress-fileupload
can manage properly.express-fileupload
would require some work.parseNested
in Payload upload config could help, but I'm not sure how deepCopyObject would behave on a buffer anyway.Steps to Reproduce
req.body
corruption can be observed by logging the body in a middleware before and after theexpress-fileupload
middleware.Detailed Description
Payload 0.10.6
The text was updated successfully, but these errors were encountered: