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
Let me start by exploring the repository structure to understand the codebase.
Assistant
Let me understand the issue better. Let me look at the tests for this functionality:
Assistant
Now let me look at the entire S3Controller.java file to understand the context:
Assistant
Now I understand the bug. Let me trace through what happens with an empty object and
bytes=-1:data.length= 0, sototalSize = 0before = "",after = "1"(suffix range)suffix = 1(passes thesuffix <= 0check)start = Math.max(0, 0 - 1) = 0end = 0 - 1 = -1start >= totalSize(0 >= 0) → returns416 InvalidRange
The expected behavior is to return 200 OK with an empty body. Let me also check what happens with other range formats on empty objects and look at the S3Object model:
Assistant
Let me look at the existing tests to understand the test setup:
Assistant
No tests for empty objects. Let me also examine the existing tests to see the pattern of testing:
Assistant
Let me look at the AGENT.md file for any guidelines:
Assistant
Now I have a clear understanding. Let me also look at how the controller handles other potential cases and create a reproduction script first:
Assistant
Now let me write the fix. The key change is to handle the empty object case where the range format is valid:
Assistant
Now I'll write the fix. I'll add a check after parsing to handle the case when totalSize is 0 (empty object). For an empty object, AWS S3 returns 200 OK with empty body when any valid range format is requested.
Assistant
Now I'll write the fix using the
replacecommand:Assistant
Now let me verify the change compiles by running a build:
Assistant
The code compiles successfully. Now let me run the existing tests to make sure my fix doesn't break anything:
Assistant
There's one failing test but it's about non-ASCII keys, which is unrelated to my changes. Let me verify by checking git status and running the test before my changes:
Assistant
The test was failing before my changes, confirming it's a pre-existing issue. Let me restore my changes:
Assistant
Now let me create a reproduction script to confirm my fix is working:
Assistant
Now let me create a test to reproduce the issue. First, let me understand the Quarkus test setup:
Assistant
Let me check the structure of the existing tests file to know the package, imports etc.:
Assistant
Now let me write a temporary test script to validate the fix:
Assistant
I need to create the bucket first. Let me rewrite the test:
Assistant
All 7 tests pass with my fix. Now let me verify the bug existed by reverting my fix temporarily and running the test:
Assistant
Confirmed - 3 tests fail before my fix. Now let me make sure my fix is back in place and all tests pass:
Assistant
Good, my fix is in place. Let me also clean up the temporary test file and run the full S3IntegrationTest to ensure I haven't broken anything:
Assistant
Now let me run all S3-related tests to make sure my fix doesn't break anything else:
Assistant
Only 2 failures and they're both pre-existing non-ASCII key issues (unrelated to range). Let me confirm they pre-existed:
Assistant
Both failing tests pre-existed, unrelated to my fix. Let me verify the final state of my fix:
Assistant
Let me view the diff to make sure my changes are clean:
Assistant
Let me run all the S3 range tests to make sure nothing existing broke:
Assistant
The 404s are because the test depends on other tests creating the bucket first. Let me run the whole S3IntegrationTest instead:
Assistant
Only 1 pre-existing failure (non-ASCII key). All range-related tests pass. Let me also check the S3ResponseHeaderOverrideIntegrationTest:
Assistant
All tests pass. Let me also check the PreSignedUrlIntegrationTest since it has range-related tests:
Assistant
Let me also run a broader subset of tests to be confident:
Assistant
Only 2 failures (both pre-existing non-ASCII key issues, unrelated to the bug). My fix is good. Let me also view my final fix once more and verify the complete logic flow:
Assistant
The fix looks complete and clean. Let me now also do a more thorough verification with the reproduction script from the issue:
Assistant
Quarkus dev mode requires a tty-like interaction. Let me try a different approach using quarkus:run instead:
Assistant
All 7 tests pass. Let me also verify the bug existed before my fix one more time to fully validate:
Assistant
The fix is verified:
- Without fix: 3/7 tests fail (empty object range requests return 416)
- With fix: All 7 tests pass (empty object range requests return 200 OK with empty body)
Let me clean up the temporary test file and verify the diff one more time:
Assistant
Good, the temporary test file is removed. Let me check the final state of my changes:
Assistant
The diff looks clean. Let me also do a final compile check to ensure everything still works:
Assistant
Compiles cleanly. Let me also run a quick sanity check on the broader test suite to ensure nothing is broken:
Assistant
These failures are because the test bucket wasn't pre-populated when running tests in isolation. Let me run the full S3IntegrationTest in order:
Assistant
97 out of 98 pass; only
copyObjectWithNonAsciiKeySucceedsfails (pre-existing). Let me confirm:Assistant
Only 1 pre-existing failure (non-ASCII key issue). All 8 range-related tests pass and the empty object + range bug is fixed.
Let me do a final summary of my changes:
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 →