ISSUE DESCRIPTION [BUG] S3 GetObject suffix range fails for empty objects Service S3 AWS…
- User
ISSUE DESCRIPTION
[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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository using command. Additionally, you can use and to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Floci version / image tag:
Assistant
I'll use the
open/editspecial commands instead.Assistant
This looks correct. Now let's check for existing tests related to range requests to verify nothing breaks, and try building.
Assistant
These use non-empty objects with size 20, so they won't hit the new empty-object branch. Now let's build the project to check compilation.
Assistant
Compiles successfully with no errors. Now let's check test suite for S3 to run relevant tests if possible.
Assistant
This failure is unrelated to our change (encoding/non-ASCII key handling). Let's verify it's pre-existing by stashing our change and re-running just that test.
Assistant
Confirmed - this test failure is pre-existing and unrelated to our change. Now let's write a quick reproduction test to confirm our fix works.
Assistant
Now let's add a temp test that PUTs an empty object then does a suffix range GET, and verify with mvn test.
Assistant
Right, when running a single test in isolation, "test-bucket" doesn't exist yet since createBucket wasn't run. Let's run the full test class instead, or just run tests up through order 33 range.
Assistant
My new test passed (99 tests run, only 1 failure which is the pre-existing unrelated one). Now let's remove the temporary test and restore the file.
Assistant
Only the S3Controller.java change remains, as intended. Let's do a final review of the diff.
Assistant
The diff is clean and minimal, containing only the fix in
S3Controller.java. Let's rebuild to make sure everything compiles fine one more time.Assistant
Compilation succeeds. Now let's clean up the temporary backup file.
Assistant
Let's verify the pre-fix code indeed exhibits the bug (416) to fully close the loop on reproduction.
Assistant
Confirmed: without the fix, we get exactly the reported 416 error. Now let's restore the fix and clean up test file.
Assistant
Everything is clean now, with only the intended fix remaining in the diff. Let's do one final full test suite run to be safe.
Assistant
Only the pre-existing unrelated failure remains (confirmed earlier via stash test). Our fix works correctly, and all range-related tests pass.
Checklist review:
- Reproduced the error: Yes. I traced the bug in
S3Controller.handleRangeRequestand confirmed via a temporary test (added then removed) that a suffix range request (bytes=-1) against an empty (0-byte) object returns416before the fix, exactly matching the issue's reported behavior (start=0, end=-1→start > end→invalidRangeResponse).
- Reproduced the error: Yes. I traced the bug in
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.