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
Now add an integration test:
- Assistant
All 99 tests pass. Let me verify the new test actually ran and reproduce the exact scenario from the bug report end-to-end:
- Assistant
It fails in isolation — likely because
test-bucketis created by an earlier ordered test. Let me check the failure detail: - Assistant
This is the file's ordered-test pattern —
test-bucketis created by an earlier test. Let me confirm other range tests behave the same in isolation: - Assistant
Full suite passes. Let me also run the other S3 test classes to make sure the refactor didn't break anything:
- Assistant
The wildcard pattern matched no tests. Retrying with a class-name pattern:
- Assistant
All 513 S3 tests pass. The fix is complete.
Summary
Bug:
GetObjectwith a suffix range (e.g.Range: bytes=-1) on a zero-byte object returned416 InvalidRange, becausehandleRangeRequestcomputedstart = 0,end = -1and thestart > endcheck rejected it. Real S3 answers this with200 OKand the whole (empty) object, which is what Trino'sreadTailon empty files relies on.Changes:
-
src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java- In
handleRangeRequest, the suffix-range branch now short-circuits whentotalSize == 0and returns the full (empty) object with200 OKinstead of falling through to the 416 path (). Malformed ranges (, , non-numeric) still return 416, as do out-of-bounds start ranges like on an empty object.
- In
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.