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 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
Let me start by understanding the issue:
- S3 GetObject with suffix range (e.g.,
bytes=-1) fails for empty objects - The problem is in
S3Controller.handleRangeRequestwhere for an empty object, it computesstart = 0andend = -1, then rejects the range - Expected behavior: A suffix range request against an existing empty object should not fail the read - it should return an empty successful read.
Let me explore the repository structure first and find the relevant code.
- S3 GetObject with suffix range (e.g.,
Assistant
Found the file. Let me look at the
handleRangeRequestmethod:Assistant
Let me open the file around line 613 to see the full method.
Assistant
Let me try again with the correct syntax.
Assistant
Now I can see the issue clearly. Let me trace through the logic for an empty object with
bytes=-1:totalSize = 0beforeis empty,after = "1", so it goes to the suffix branch (line 629)suffix = 1(which is > 0, so it passes the check on line 631)start = Math.max(0, 0 - 1) = 0end = 0 - 1 = -1- Then on line 644:
start >= totalSize→0 >= 0→ true → returns 416 InvalidRange
Let me create a reproduction script first to confirm the issue, then fix
Assistant
Let me also check the test files to understand the testing setup
Assistant
Let me search for range-related tests in the S3 integration test
Assistant
Now I understand the issue clearly. Let me look at the full
handleRangeRequestmethod once more and then implement the fix:Assistant
Now I have a clear picture. Let me implement the fix. The issue is that after computing
start=0, end=-1for an empty object, the validation on line 644 rejects the range becausestart >= totalSize(0 >= 0) orstart > end(0 > -1).I need to add a special case: for empty objects, if the range request is syntactically valid and starts at byte 0 (suffix ranges or
bytes=0-), we should return a 206 with empty bodyAssistant
Now let me insert this code block after line 643 (end of try-catch) and before line 644 (the validation check
Assistant
The fix looks good. Let me now run the S3 integration tests to verify nothing is broken
Assistant
The one failure (
copyObjectWithNonAsciiKeySucceeds) is a pre-existing issue unrelated to my change. Let me verify the range-related tests passed:Assistant
Let me check the test results more carefully.
Assistant
97 out of 98 tests pass, and the only failure (
copyObjectWithNonAsciiKeySucceeds) is pre-existing and unrelated to my change. All range-related tests pass.Let me also verify the fix handles the edge cases properly by reviewing the final code once more:
Assistant
The code looks correct. Let me verify the changes with git diff
Assistant
Let me also check the copy-source-range handling to ensure consistency - this is also a range-related path
Assistant
Let me check how
copySourceRangeis used in the copyObjectAssistant
Let me check the S3 service layer to see if there's any range logic there too
Assistant
Let me look at the copySourceRange handling in S3Service
Assistant
The
copySourceRangeinS3Servicehandles a different format (explicitSTART-ENDonly, no suffix support). The issue is specifically aboutGetObjectwith suffix ranges, which my fix addresses.Let me also quickly verify the fix compiles correctly
Assistant
Compilation succeeds. Let me run just the range-related tests to confirm they all
Assistant
The test selection syntax might be wrong. Let me try running a single test to
Assistant
The individual test runs might have isolation issues. Let me run the full test class again
Assistant
The full test suite shows only 1 pre-existing failure. The individual test failures are due to test isolation issues (tests dependent on shared state from other tests). All range-related tests pass in the full suite.
Let me write a quick script to verify the fix works for the exact scenario from the issue description
Assistant
Let me verify the surefire report to confirm range tests passed
Assistant
Let me verify the pre-existing failure isn't caused by my change. I'll stash and run the
Assistant
Confirmed: The 1 test failure (
copyObjectWithNonAsciiKeySucceeds) is pre-existing and not caused by my change. Both with and without my fix, the exact same 98 tests run with 1 failure.Now let me verify the final state of the fix:
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
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →