Skip to content

S3: CompleteMultipartUpload does not enforce the 5 MB non-final part minimum (EntityTooSmall unreachable) #400

Closed

Description

@scttfrdmn

Summary

completeMultipartUpload does not enforce S3's 5 MB minimum on non-final parts, so EntityTooSmall
is unreachable.

Verified against 103c843 (v0.76.0):

$ grep -rn "EntityTooSmall" --include="*.go" .
(no matches)

emulator/s3_plugin.go:1216 assembles the parts and returns 200 regardless of individual part
sizes.

Why this matters to me

objectfs computes multipart chunk sizes from the file size
via a CalculateOptimalChunkSize function with several size brackets. One bracket divides a base
chunk size by two:

if fileSize < multipartThreshold*2 {
    chunkSize = baseChunkSize / 2
}

With a small enough configured MultipartChunkSize, that lands under 5 MB and every multipart upload
in that size band fails at CompleteMultipartUpload — after all the parts have been uploaded and
paid for. There's now a s3MinPartSize floor guarding it, but the only thing keeping that floor
correct is a unit test asserting arithmetic against itself, which is precisely the kind of test that
tracks a bug rather than catching it.

I want the emulator to be the authority instead. If substrate rejects the upload the way S3 does, the
test asserts behaviour rather than re-deriving my own formula — which is the difference between a
test that catches a regression and one that ratifies it.

This also matters for a live bug I'm fixing: on CompleteMultipartUpload failure, objectfs does not
abort the upload, so all the uploaded parts leak and keep billing indefinitely (there is no
ListMultipartUploads call anywhere in the codebase to find them again). EntityTooSmall is the
cleanest way to deterministically trigger a Complete failure so I can assert the cleanup happens.
Which brings me to a request that's arguably more important than the validation itself —

What I need

1. EntityTooSmall on Complete. If any part other than the highest-numbered one is smaller than
5 MB (5,242,880 bytes), return 400 EntityTooSmall with the standard XML body, which in real S3
includes the offending part number and both sizes:

<Error>
  <Code>EntityTooSmall</Code>
  <Message>Your proposed upload is smaller than the minimum allowed size</Message>
  <ETag>...</ETag>
  <MinSizeAllowed>5242880</MinSizeAllowed>
  <ProposedSize>1024</ProposedSize>
  <PartNumber>1</PartNumber>
</Error>

The last part may be any size, including zero. A single-part upload may be any size.

2. Nothing — ListMultipartUploads already exists at emulator/s3_plugin.go:1369, along with
abortMultipartUpload at :1333. That's the piece I assumed I'd have to ask for, and it's the piece
that makes this issue worth filing: with those two plus EntityTooSmall, I can assert the property I
actually care about — no orphan upload remains after a failed Complete — by observing the emulator
rather than by asserting that my own code called Abort.

While in the area, the other Complete-time validations would be welcome for the same reason (each
turns a class of my bugs into a failing test rather than a production surprise):

Condition Real S3
Part numbers not in ascending order 400 InvalidPartOrder
A referenced part was never uploaded 400 InvalidPart
Supplied ETag doesn't match the stored part 400 InvalidPart
uploadId unknown or already completed/aborted 404 NoSuchUpload
Zero parts in the request 400 MalformedXML

InvalidPartOrder and InvalidPart are the two I'd prioritise after EntityTooSmall, since
objectfs assembles part lists concurrently and an ordering bug there is silent data corruption rather
than an error.

Acceptance

A test uploading two parts where the first is 1 KiB, asserting 400 EntityTooSmall and that no
object was created at the key; a test asserting a 1 KiB final part succeeds; and a test asserting
ListMultipartUploads reports the still-open upload after the failed Complete, then reports nothing
after AbortMultipartUpload.

Activity

  1. added
    type: feature
    area: s3
    priority: medium
    on Jul 30, 2026
  2. added this to the v0.79.0 milestone on Jul 31, 2026
  3. added a commit that references this issue on Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: s3priority: mediumtype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions