The Wayback Machine - https://web.archive.org/web/20220627185946/https://github.com/vapor/vapor/issues/2650
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

Multipart Errors are reported as internal server errors #2650

Open
0xTim opened this issue Jul 12, 2021 · 3 comments
Open

Multipart Errors are reported as internal server errors #2650

0xTim opened this issue Jul 12, 2021 · 3 comments

Comments

@0xTim
Copy link
Member

@0xTim 0xTim commented Jul 12, 2021

When sending a request body that decodes a Content type. If the request is sent as multipart with the right header set, but the body is empty, a 500 error is returned. This can cause problems with apps that have automatic reporting for internal server errors as it should be reported as a bad request

@0xTim 0xTim added the bug label Jul 12, 2021
@0xTim 0xTim added good first issue and removed bug labels Aug 6, 2021
@JakeTiritilli
Copy link

@JakeTiritilli JakeTiritilli commented Aug 7, 2021

I’ll work on trying to fix this one.

paunik pushed a commit to paunik/vapor that referenced this issue Aug 22, 2021
In order to prevent 5xx internal error we try to:

- validate number of parameters in FormDataDecoder so we can detect when only boundary is present.
@BennyDeBock BennyDeBock added this to To do in Beginner Issues Mar 4, 2022
@jareyesda
Copy link

@jareyesda jareyesda commented May 8, 2022

@0xTim @BennyDeBock, Is this still an issue? Was looking into it but it seems like it was resolved.

The private _ContentContainer struct for a Request object has its decode method throw Abort(.unprocessableEntity) when body is nil. Line 76 inside Request.swift.

Here's a snippet of the decode method I'm referencing:

func decode<D>(_ decodable: D.Type, using decoder: ContentDecoder) throws -> D where D : Decodable {
   guard let body = self.request.body.data else {
       self.request.logger.debug("Request body is empty. If you're trying to stream the body, decoding streaming bodies not supported")
       throw Abort(.unprocessableEntity)
   }
   return try decoder.decode(D.self, from: body, headers: self.request.headers)
}
paunik pushed a commit to paunik/vapor that referenced this issue May 23, 2022
In order to prevent 5xx internal error we try to:

- validate number of parameters in FormDataDecoder so we can detect when only boundary is present.
@paunik
Copy link
Contributor

@paunik paunik commented May 23, 2022

@jareyesda I have opened MR that covers that some while ago, now i have rebased and ran the tests, seems that issue is still present. If You can check, do I need to add some more things or we should close this MR.
Best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue
4 participants