Repository navigation
Description
Summary
S3Plugin.getObject ignores the Range request header. Every GET returns the full object body
with 200 OK, so ranged reads cannot be tested against the emulator.
Verified against 103c843 (v0.76.0):
$ grep -rn "Content-Range\|StatusPartialContent\|InvalidRange\|\"Range\"" --include="*.go" . | grep -v _test
(no matches)
emulator/s3_plugin.go:592-596 builds the response headers unconditionally from the stored
object — Content-Type, ETag, Last-Modified, Content-Length: obj.Size — with no inspection
of req.Headers["Range"] and no 206 path.
docs/services.md:190 currently claims this works:
| GetObject | Supports Range header |
That row should be corrected either way, since a consumer reading it will write tests that silently
pass against full-object responses.
Why this matters to me
I'm using substrate as the in-process AWS for objectfs, a
FUSE filesystem over S3. Ranged GET is not an edge case there — it is the primary read path. A
FUSE read(fd, buf, 4096) at offset N becomes GetObject(key, range: bytes=N-N+4095). Nearly every
read the filesystem issues is ranged.
An audit of objectfs v0.10.0 found that its worst defects live specifically in ranged-read handling:
- a reachable panic on a negative length (
data[offset:offset+size]withsize < 0→
slice bounds out of range [100:99], which kills the mount process and takes every open file
descriptor with it), - read amplification where a 4 KiB ranged read fetched an entire 10 GiB object,
- an off-by-request-length cache key that made ranged reads structurally uncacheable.
None of those are testable without a 206 path. This is the single capability blocking the objectfs
read-path test suite, which is why I'd call it P0 — everything else on my substrate wishlist can be
worked around; this cannot.
What I need
GET with a Range header on getObject, per
RFC 9110 §14 as S3 implements it:
| Request | Response |
|---|---|
Range: bytes=0-99 on a 1000-byte object |
206, Content-Range: bytes 0-99/1000, Content-Length: 100, first 100 bytes |
Range: bytes=900- |
206, Content-Range: bytes 900-999/1000, 100 bytes |
Range: bytes=-100 (suffix) |
206, Content-Range: bytes 900-999/1000, last 100 bytes |
Range: bytes=0-99999 (end past EOF) |
206, Content-Range: bytes 0-999/1000 — S3 clamps, does not error |
Range: bytes=1000-1099 (start at/past EOF) |
416 InvalidRange, Content-Range: bytes */1000 |
Range: bytes=abc / malformed |
200 with the full object — S3 ignores unparseable ranges |
Range: bytes=0-99,200-299 (multi-range) |
S3 returns the full object 200; it does not do multipart/byteranges |
No Range header |
200, unchanged from today |
Two details that are easy to get wrong and that I would be testing against:
ETagandLast-Modifiedmust be identical on the 206 and the 200. objectfs is going to key
its cache on(key, chunkIndex, etag), so a ranged response that omits or alters the ETag would
make the emulator disagree with real S3 in exactly the way that hides cache bugs.- The
416body should be the standard S3 XML error (<Code>InvalidRange</Code>with
<ActualObjectSize>), since the AWS SDK maps that code to a typed error the caller matches on.
Interaction with existing features: ranged GET should compose with versionId (range applies to the
selected version) and should return 416 rather than a range on a zero-byte object.
Acceptance
A table test over the eight rows above asserting status, Content-Range, Content-Length, and body
bytes, plus one asserting ETag equality between a 200 and a 206 of the same object. Then
docs/services.md:190 becomes true.
Happy to send a PR if you'd rather — I'm going to be reading this code closely regardless. Let me
know which you prefer.
Activity
feat(s3): honor the Range header on GetObject and HeadObject (#396) (#…
chore(release): v0.80.0 (#423)