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 explore the repository structure first.
Assistant
Let me find the S3Controller file mentioned in the issue.
Assistant
Let me look at the S3Controller and find the
handleRangeRequestmethod.Assistant
Now let me look at the existing tests for range requests to understand conventions.
Assistant
Let me look at the range test details to understand the conventions.
Assistant
Let me look at the test setup to understand how test objects are created.
Assistant
Let me look at the compatibility tests directory and check how the S3Service stores object data.
Assistant
No range tests in compatibility tests. Let me look at the S3FeaturesTest to understand patterns and look for any empty object tests.
Assistant
Let me look at the
appendObjectHeadersmethod and the surrounding code to understand the helper methods.Assistant
Let me check the full
handleRangeRequestmethod and reproduce the issue. First, let me look at the exact lines to edit.Assistant
Now let me create a temporary reproduction test to confirm the issue. Let me look at the test setup first.
Assistant
Let me check the test configuration for the port used.
Assistant
Now let me create a temporary reproduction test to confirm the bug.
Assistant
I've reproduced the bug — the suffix range request on an empty object returns 416. Now let me implement the fix in
handleRangeRequest.Assistant
Now let me implement the fix. I'll add handling for empty objects after the range parsing (so syntactically malformed ranges still return 416), before the satisfiability check.
Assistant
The fix looks good. Let me extend the temporary test to cover edge cases and re-run it.
Assistant
Let me confirm the test results summary explicitly.
Assistant
All edge cases pass. Now let me run the existing S3 integration tests to ensure I didn't break anything.
Assistant
There's a failure in
copyObjectWithNonAsciiKeySucceedswhich seems unrelated to range handling. Let me check if it's a pre-existing failure by examining it and testing against the original code.Assistant
This failure is about copying objects with non-ASCII keys — unrelated to my range change. Let me verify it's pre-existing by stashing my changes and running just that test.
Assistant
Confirmed —
copyObjectWithNonAsciiKeySucceedsis a pre-existing failure unrelated to my change (it fails on the original code too). Let me verify all the range-related tests pass with my fix.Assistant
These subset failures are because the tests depend on ordered setup (bucket/object creation) that doesn't run when only a subset is selected. The full class run earlier showed only the pre-existing
copyObjectWithNonAsciiKeySucceedsfailure. Let me re-run the full class to confirm all range tests pass.Assistant
The
!in<<<is being interpreted by bash history expansion. Let me avoid that.Assistant
Only the pre-existing unrelated failure remains. All range tests pass. Let me also run the S3ServiceTest unit tests and a couple of related integration tests to be thorough.
Assistant
The S3ServiceTest error is also about non-ASCII key handling (
InvalidPath ... unmappable characters), an environment/charset issue unrelated to my range fix. Let me confirm it's pre-existing by stashing.Assistant
Both pre-existing failures (
copyObjectWithNonAsciiKeySucceedsandcopyObjectWithNonASCIIKey) are confirmed unrelated environment/charset issues — they fail identically on the original code. My fix introduces no new breakage.Now let me clean up the temporary test file and review the final diff.
Assistant
The diff is clean. Let me do a final compile check to ensure the source compiles correctly.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.