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 I'll implement the fix. Real S3 ignores a suffix range on an empty object and serves the full (empty) object with a 200:
- Assistant
Now add an integration test. Let me check how the test file is set up (bucket creation, imports):
- Assistant
Both new tests ran and passed. Let me also run the other S3 test suites that touch ranges to make sure nothing regressed:
- Assistant
All green. The fix is complete:
Changes
src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.javahandleRangeRequest(line ~640): when a suffix range (bytes=-N, N > 0) targets a zero-byte object, it now returnsnullinstead of computingstart=0, end=-1and rejecting the range with 416.- The GetObject caller (line ~593): treats that
nullas "fall through to the normal full-object path", so the request returns 200 OK withContent-Length: 0and an empty body — matching real S3's behavior, which ignores suffix ranges on empty objects. This is exactly what Trino'sTrinoInput.readTail(...)expects for zero-byte files.
Behavior deliberately preserved: start-based ranges on empty objects (e.g.
bytes=0-) still return416 InvalidRange, as real S3 does, andbytes=-0/ malformed ranges remain 416.src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java— two new tests:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.