Skip to content

Return a clear error when a multipart upload has no file part - #261

Open
mmoyles87 wants to merge 1 commit into
hyperledger-firefly:mainfrom
mmoyles87:220-multipart-no-file-no-eof
Open

mmoyles87 wants to merge 1 commit into
hyperledger-firefly:mainfrom
mmoyles87:220-multipart-no-file-no-eof

Conversation

@mmoyles87

@mmoyles87 mmoyles87 commented Oct 19, 2026 •

Copy link
Copy Markdown

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.

getFilePart now returns a new error, FF00262 No file found in multi-part form input. The file part must have a filename, still HTTP 400.

Only a bare io.EOF from NextPart, 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 is err == io.EOF and not errors.Is, and a test pins it.

Tests added:

  1. File part with no filename (the firefly#220 repro)
  2. Form fields only, no file part
  3. Truncated body with no closing boundary, which must stay FF00161

The first two fail on main.

Out of scope, both older than this change: Mimetype is set from the Content-Disposition header at pkg/ffapi/handler.go:125, and the io.ReadAll error for form fields is ignored at pkg/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.

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>
@mmoyles87
mmoyles87 requested a review from a team as a code owner October 19, 2026 13:47
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.

1 participant