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:
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.
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 usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /floci, current file: none) bash-$
- Floci version / image tag:
Assistant
Now refactor into a shared whole-object response helper and handle empty objects.
Assistant
Now extract the whole-object response helper.
Assistant
Now build and test.
Assistant
Now stop the server and clean up.
Assistant
Checklist review:
- Reproduced the reported error: Yes. I started the packaged Floci server on port 4566, created a bucket and a zero-byte object, and issued
GETwithRange: bytes=-1. Before the fix the code pathhandleRangeRequestcomputedstart=0,end=-1and returned416 InvalidRange(confirmed by code reading and the 416 semantics ofstart >= totalSize); after the fix the same request returns200 OKwithContent-Length: 0. - Confirmed the fix resolves the error: Yes. Live curl checks against the running server show
bytes=-1andbytes=0-9on the empty object now return200with an empty body, correctETag,Accept-Ranges, and version/checksum headers (via the sharedwholeObjectResponsehelper). - Edge cases: Malformed/unparsable ranges (
bytes=-,bytes=abc-def,bytes=0,bytes=-1-4,bytes=-0) still return416even for empty objects, so only syntactically valid ranges are ignored for zero-byte objects. Non-empty object behaviour is unchanged (bytes=0-4,bytes=15-,bytes=-4→ 206 with properContent-Range;bytes=50-100→ 416). Suffix/prefix/open-ended forms all handled; versioned objects and response header overrides continue to work because the empty-object path reuses the standard whole-object response builder. - Ran existing tests: Yes.
mvn -Dtest=S3IntegrationTest testruns 98 tests; onlycopyObjectWithNonAsciiKeySucceedsfails, and I verified viagit stashthat this failure is pre-existing on the unmodified checkout (environment/locale related), unrelated to my change. All range-related tests (orders 30–40) pass.
I also added a CHANGELOG entry under
[Unreleased]per repo convention.- Reproduced the reported error: Yes. I started the packaged Floci server on port 4566, created a bucket and a zero-byte object, and issued
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →