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
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 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
Let me start by understanding the issue:
-
When doing a GetObject with a suffix byte range (e.g.,
bytes=-1) on an empty S3 object, Floci returns416 InvalidRangeinstead of successfully returning the empty object. -
The issue is in
S3Controller.handleRangeRequestwhere it computesstart = 0andend = -1for an empty object, then rejects the range.
Let me explore the repository structure and find the relevant code.
-
Assistant
Let me look at the S3Controller.java file, specifically the handleRangeRequest method.
Assistant
The open command didn't accept the FILE argument. Let me check the format again. According to the documentation:
open [OPTIONS] [FILE] [LINE_NUMBER]
So I should use:
codeopen /floci/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.javaAssistant
Let me find the handleRangeRequest method in
Assistant
The file is open. Let me use grep to find the handleRangeRequest method.
Assistant
Let me look at the handleRangeRequest method. Let me go to line 613.
Assistant
Now I can see the issue. Let me look at the calling code too:
Assistant
Now I understand the issue clearly. Let me look at the exact lines I need to modify:
For an empty object (totalSize = 0) with suffix range
bytes=-1:start = Math.max(0, 0 - 1) = 0end = 0 - 1 = -1- Check at line 644:
start (0) > end (-1)→ returns 416
The fix: for empty objects with a valid suffix range, we should return the full (empty) object successfully instead of 416.
Let me first create a reproduce script, then apply the fix.
Assistant
Let me see the test file to understand existing range tests:
Assistant
Good. Now let me apply the fix. The issue is in lines 629-635 of
handleRangeRequest. WhentotalSize == 0and we have a valid suffix range, we should return the full emptyAssistant
Let me try using the
replacecommand instead, with a multi-line syntaxAssistant
The fix looks correct. Now let me verify the build compiles and run the relevant tests.
Assistant
Compilation succeeded. Now let me run the S3 integration tests to make sure the existing range tests pass and nothing is broken.
Assistant
The failure
copyObjectWithNonAsciiKeySucceedsseems unrelated to my change. Let me verify by running just the range-related tests:Assistant
Let me look at the test to understand the test structure and see if 404 errors are related to my change or pre-existing:
Assistant
Let me look at the range tests:
Assistant
The 404 errors were because I ran tests in isolation without their prerequisites. Let me run all the S3 tests to check:
Assistant
The
copyObjectWithNonAsciiKeySucceedsfailure is pre-existing (same result without my change). Let me restore my fix:Assistant
Now let me run the full S3IntegrationTest with my change to confirm there are no regressions:
Assistant
Only the pre-existing
copyObjectWithNonAsciiKeySucceedsfailure remains. All 97 other tests pass. Let me verify the diff of my change:Assistant
Let me verify the
appendObjectHeadersmethod signatures to make sure I'm using the correct one:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.