Repository navigation
Conversation
When a multi-part form ends without any part that has a filename, NextPart returns io.EOF and getFilePart wrapped it as FF00161 "Error reading multi-part form input: EOF". That reads like a broken upload, when the real problem is that no file was sent, for example a file part with an empty filename. Return a new 400 error, FF00262, for that case. Other read failures, including a body that ends before the closing boundary, still return FF00161. Refs hyperledger-firefly/firefly#220 Signed-off-by: Matt Moyles <matt@mattmoyles.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs hyperledger-firefly/firefly#220
A multipart request whose file part has no filename, or that has no file part at all, came back as FF00161
Error reading multi-part form input: EOF(the issue quotes core's older FF10218). That reads like a broken upload, when the real problem is that no file was sent.getFilePartnow returns a new error, FF00262No file found in multi-part form input. The file part must have a filename, still HTTP 400.Only a bare
io.EOFfromNextPart, which is the clean end after the final boundary, maps to FF00262. A truncated or malformed body comes back wrapped and keeps FF00161. That is why the check iserr == io.EOFand noterrors.Is, and a test pins it.Tests added:
The first two fail on main.
Out of scope, both older than this change:
Mimetypeis set from theContent-Dispositionheader atpkg/ffapi/handler.go:125, and theio.ReadAllerror for form fields is ignored atpkg/ffapi/handler.go:118.Using "Refs" rather than "Fixes" because core pins common v1.6.3, so firefly#220 can close once this is released and core picks it up.