Untitled conversation
- User
[BUG] S3 GetObject suffix range fails for empty objects
Service
S3
AWS API Action
GetObject with the
Rangeheader set to a suffix byte range, for examplebytes=-1.Expected behavior
A suffix range request against an existing empty object should not fail the read. This is exercised by Trino's S3 filesystem compatibility test for empty files, where
TrinoInput.readTail(...)reads an existing zero-byte S3 object and expects an empty successful read.Actual behavior
Floci returns
416 InvalidRangefor the same request becauseS3Controller.handleRangeRequestcomputesstart = 0andend = -1for an empty object, then rejects the range.In Trino's Floci-backed S3 filesystem test this surfaces as:
software.amazon.awssdk.services.s3.model.S3Exception: The requested range is not satisfiable. (Service: S3, Status Code: 416)Reproduction
# Start Floci on localhost:4566 first. aws --endpoint-url http://localhost:4566 s3 mb s3://range-empty-repro printf '' > /tmp/empty-object aws --endpoint-url http://localhost:4566 s3 cp /tmp/empty-object s3://range-empty-repro/empty aws --endpoint-url http://localhost:4566 s3api get-object \ --bucket range-empty-repro \ --key empty \ --range 'bytes=-1' \ /tmp/range-empty-outputEnvironment
- Floci version / image tag:
floci/floci:1.5.21 - Java SDK version (if applicable): observed with Trino's AWS SDK v2 S3 client tests
- How you're running Floci (Docker / native /
mvn quarkus:dev): Docker via Testcontainers
Interface
No new interfaces are introduced.
- Floci version / image tag:
- Assistant
Now let me check existing tests for range requests:
- Assistant
Now I'll implement the fix. Real S3 returns a
200 OKwith the full (empty) body for a suffix range on a zero-byte object, rather than 416. I'll extract the full-object response into a helper and use it for that case: - Assistant
Now add an integration test. Let me check the test file structure:
- Assistant
I'll add tests right after
getObjectWithSuffixRange, self-contained with their own empty object: - Assistant
All 99 tests pass, 0 failures. Let me confirm the new test was included:
- Assistant
The presigned URL path also mentioned Range — let me verify it routes through the same handler:
- Assistant
That goes through the same
S3ControllerGET endpoint, so it's covered by the fix.Summary
Fix (
src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java):- In
handleRangeRequest, the suffix-range branch (bytes=-N) now short-circuits when the object is empty: instead of computingstart=0, end=-1and rejecting with416 InvalidRange, it returns a200 OKwith the full (empty) body — matching real S3's behavior for suffix ranges on zero-byte objects (the case Trino'sreadTailon empty files exercises). - Extracted the existing full-object
200response construction into afullObjectResponse(obj, overrides)helper so both the normal GET path and the empty-suffix-range path share identical headers (Content-Type,ETag,Last-Modified,Accept-Ranges, version ID, metadata headers). - Behavior for start-based ranges on empty objects (e.g.
bytes=0-) is unchanged and still returns , as real S3 does.
- In
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.