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 start by exploring the repository structure and finding the relevant code mentioned in the issue.
Assistant
I'll explore the repository structure and find the relevant code mentioned in the issue.
Assistant
Let me look at the
handleRangeRequestmethod and the surrounding code.Assistant
Now let me look at the existing tests for range handling to understand the conventions and expected behavior.
Assistant
Now let me look at the
invalidRangeResponseandappendObjectHeadersmethods to understand the helpers available.Assistant
Let me look at the
appendObjectHeadersmethods andinvalidRangeResponseto understand the signatures.Assistant
Now let me understand the test setup to know how objects are created in the integration test.
Assistant
Now let me create a temporary reproduction test to confirm the bug. Let me first check how tests are run and the test infrastructure.
Assistant
Now let me create a temporary reproduction test to confirm the bug.
Assistant
I need to add the static import for
equalTo. Let me fix the test.Assistant
I've confirmed the bug: the suffix range request on an empty object returns 416 instead of 200. Now let me apply the fix to
handleRangeRequest.Assistant
I've confirmed the bug. Now let me apply the fix. I'll add a special case for suffix ranges against empty objects, returning a successful 200 response with an empty body (matching real S3 behavior).
Assistant
Now let me add the
fullObjectResponsehelper method right afterhandleRangeRequest(after line 671).Assistant
Let me verify
getSize()exists onS3Objectand check its behavior.Assistant
getSize()returns along, consistent with the existing GET path. Now let me re-run the reproduction test to confirm the fix.Assistant
The reproduction test passes now. Let me run the existing S3 integration tests to make sure I didn't break anything, especially the range tests.
Assistant
There's a failure in
copyObjectWithNonAsciiKeySucceeds. Let me check whether this is related to my change or pre-existing. Let me look at the test.Assistant
This test is unrelated to range handling. Let me verify it's a pre-existing failure by stashing my changes and running just that test.
Assistant
Confirmed —
copyObjectWithNonAsciiKeySucceedsfails even on the original code, so it's a pre-existing failure unrelated to my change. Let me run the range-specific tests to confirm they all pass with my fix.Assistant
These tests fail in isolation because they depend on the ordered setup tests (createBucket, putObject). The earlier full run showed only
copyObjectWithNonAsciiKeySucceedsfailing (pre-existing). Let me confirm the range tests passed in the full run by checking the surefire report.Assistant
That report is from the isolated run, not the full run. Let me re-run the full
S3IntegrationTestto get a clean report and confirm the range tests pass.Assistant
Only the pre-existing
copyObjectWithNonAsciiKeySucceedsfailure remains; all range tests pass. Let me extend my temporary repro test to verify edge cases before cleaning up.Assistant
All edge cases pass. Let me also run the multipart test (which uses ranges for part-copy) to be safe, then clean up.
Assistant
Now let me remove the temporary reproduction test file.
Assistant
Let me review the final diff of my changes.
Assistant
Let me do a final compile check to ensure everything compiles correctly.
Assistant
The code compiles cleanly. Let me verify the final state of the changed method one more time.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.