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:
textsoftware.amazon.awssdk.services.s3.model.S3Exception: The requested range is not satisfiable. (Service: S3, Status Code: 416)Reproduction
bash# 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
I'll locate the S3 range-handling code and fix empty-object suffix ranges, then run focused tests.
- Assistant
Implementing the fix: suffix ranges on empty objects should return 206 with an empty body instead of 416.
- Assistant
Isolated tests failed due to missing setup data; running the full S3 integration test class.
- Assistant
Verifying the fix with the bug report's reproduction steps:
- Assistant
Fixed the S3 suffix-range bug for empty objects.
Problem
For a zero-byte object,
handleRangeRequestparsedbytes=-1asstart = 0andend = totalSize - 1 = -1, then rejected it with416 InvalidRangebecausestart > end.Fix
In
S3Controller.handleRangeRequest, suffix ranges on empty objects now return206 Partial Contentwith an empty body instead of416:634:636:src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.javaif (totalSize == 0) { return emptySuffixRangeResponse(obj, overrides); }The new
emptySuffixRangeResponsehelper mirrors other range responses:- Status
206 Content-Range: bytes 0-0/0
- Status
- Assistant
The Floci server on port 4567 started successfully and was used for manual verification of the empty-object suffix-range fix. It was stopped afterward once the curl checks passed.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.