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, 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 to understand the codebase and find the relevant files.
Assistant
I'll start by exploring the repository structure.
Assistant
Now I can see the issue. Let me examine the
handleRangeRequestmethod more closely and look at theinvalidRangeResponsemethod.Assistant
Now I understand the issue. Let me look at existing tests to understand conventions and expected behavior.
Assistant
Let me look at the test setup to understand how objects are created.
Assistant
Let me look at the test setup more and understand the test framework, and search for any empty object handling.
Assistant
Now let me understand the issue clearly. The problem is in
handleRangeRequest. When the object is empty (totalSize = 0), a suffix range likebytes=-1computesstart = Math.max(0, 0 - 1) = 0andend = 0 - 1 = -1. Then the checkstart < 0 || start >= totalSize || start > endtriggers becausestart (0) >= totalSize (0)andstart (0) > end (-1).Let me write a reproduction script first. But let me first check how tests are run.
Assistant
Now I understand the issue. Let me look at the exact code section to fix and check the S3Object class for the
getSizemethod.Assistant
Now let me open the
handleRangeRequestmethod to make the fix.Assistant
Now I understand the issue completely. Let me write a reproduction test first to confirm the bug. Let me check how the tests run and whether the app can be started.
Assistant
Now let me apply the fix. I'll add a check at the start of
handleRangeRequestto handle the empty object case by returning a 200 OK with empty body, mirroring real S3 behavior.Assistant
No python available. Let me use the
editcommand directly.Assistant
The fix looks good. Now let me create a reproduction test to confirm the fix works. Let me first check how to compile and run tests.
Assistant
Let me check the test configuration and how the test data directory is set up.
Assistant
Now let me create a temporary reproduction test to verify the fix.
Assistant
The test ran but I need to see the result. Let me check the test report.
Assistant
The test passes. Now let me confirm the test would fail WITHOUT my fix (to verify it actually reproduces the bug). Let me temporarily revert the fix.
Assistant
The test fails without the fix (returns 416 instead of 200), confirming the bug. Now let me restore my fix.
Assistant
The fix is restored. Now let me verify the fix passes again and also run the existing S3 range tests to make sure nothing breaks.
Assistant
The fix passes. Now let me run the existing S3 integration tests to ensure I didn't break anything, especially the range tests.
Assistant
There's one failure but it looks unrelated (
copyObjectWithNonAsciiKeySucceeds). Let me verify it's pre-existing by checking against the original code without my changes.Assistant
The
copyObjectWithNonAsciiKeySucceedsfailure is pre-existing and unrelated to my change (it fails on the original code too). Let me restore my fix.Assistant
My fix is restored. The pre-existing failure is unrelated. Now let me run the specific range-related test methods to confirm they all pass with my change.
Assistant
These fail because they depend on ordered setup tests. Let me run the full
S3IntegrationTestclass and confirm only the pre-existing unrelated failure remains.Assistant
All range tests pass; only the pre-existing unrelated failure remains. Let me expand my temporary reproduction test to cover more edge cases (different range forms on empty objects).
Assistant
All 4 edge case tests pass. Now let me clean up by removing my temporary reproduction test before submitting.
Assistant
Let me review the final diff of my change.
Assistant
Let me do a final compile check to ensure the code compiles cleanly.
Assistant
The code compiles cleanly. Let me provide a summary of my work and the checklist.
Summary
The issue was that
S3Controller.handleRangeRequestreturned416 InvalidRangefor suffix range requests (e.g.,bytes=-1) against empty (zero-byte) objects. This broke Trino's S3 filesystem compatibility test, which reads the tail of an empty file and expects an empty successful read.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.