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
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 uses to get the changes that need to be submitted. - Floci version / image tag:
- Assistant
I’ll inspect the repository to locate the S3 range handling and its tests, then reproduce the relevant behavior if practical. I’ll make the smallest standards-compatible fix for empty suffix ranges, run focused and broader tests, review the diff, and only then submit.
- Assistant
The range logic is in
S3Controller. I’ll inspect that method and nearby S3 tests, especially how response bodies and range validation are structured, so the empty-object behavior is corrected without changing valid-range semantics. - Assistant
The current parser correctly rejects ordinary unsatisfiable ranges, but an empty object has no byte interval to represent. For the requested compatibility behavior, the safest response is a successful empty GET-style response (status 200), preserving object metadata and
Content-Length: 0; emitting a malformed206 Content-Rangesuch as0--1/0would be invalid HTTP/S3 semantics. I’ll verify the existing integration setup and then implement a dedicated empty-object branch. - Assistant
I’ll preserve validation for malformed ranges and for non-suffix ranges on empty objects. Only a syntactically valid positive suffix range (
bytes=-N) on a zero-byte object will return the same successful empty-object representation as an un-ranged GET, including metadata andAccept-Ranges. This avoids inventing an invalidContent-Range. - Assistant
The first edit attempt could not run because this environment lacks
python3; no file was changed. I’ll apply the same targeted edit using the available shell tooling, then compile and run the focused S3 tests. - Assistant
The targeted change is now present and passes whitespace checks. I’ll run the S3 integration test class (including existing range cases) to catch compile/runtime issues, then inspect any failures and verify the final diff.
- Assistant
The Maven wrapper did not start because
HOMEis unset in the shell, rather than because of the code. I’ll rerun with a temporary validHOMEvalue and keep the test invocation focused. - Assistant
The focused S3 suite started successfully and exercised all existing range tests; its sole failure is an unrelated pre-existing non-ASCII copy test (
copyObjectWithNonAsciiKeySucceeds, 400 vs 200), occurring before/independent of this change. I’ll run a compile/package check and inspect reports/diff. Since adding repository tests is disallowed, I’ll use source-level verification of the new branch and existing range assertions rather than commit a test. - Assistant
Compilation/package validation succeeds, and
git diff --checkis clean. The only modified file is the S3 controller. The implementation handlesbytes=-NwithN>0and zero data as a 200 empty response, whilebytes=0-0,bytes=-,bytes=0, malformed, and other unsatisfiable ranges retain their prior 416 behavior. I’ll review the final diff once more and submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.