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. The problem is about S3 GetObject with suffix range (e.g.,
bytes=-1) failing for empty objects. When an object is empty (0 bytes), a suffix range request likebytes=-1should return successfully with an empty response, but instead Floci returns416 InvalidRange.Let me explore the repository structure first.
Assistant
This is a Java/Maven project. Let me find the S3Controller and look at the handleRangeRequest method.
Assistant
Let me look at the S3Controller.java file to find the handleRangeRequest method.
Assistant
Let me look at the
handleRangeRequestmethod in detail.Assistant
Let me use the correct command format.
Assistant
Let me try the correct format.
Assistant
Now I can see the issue clearly. Let me also look at the test file for context.
Assistant
Let me look at the existing suffix range test at line 481.
Assistant
Now I have a clear understanding of the issue. Let me look at the full method once more and then implement the fix.
Assistant
Now I understand the issue completely. Let me create a script to reproduce the issue and then implement the fix.
First, let me look at how the tests are run to understand the build
Assistant
Let me look at the test setup to understand how objects are created:
Assistant
Now I have a clear understanding. Let me implement the fix. The issue is that for
bytes=-1on an empty object (totalSize=0),start=0andend=-1, and the validation at line 644 rejects it becausestart >= totalSize(0 >= 0).I'll modify the suffix range handling to return the full empty response for empty objects:
Assistant
Let me try using the heredoc syntax for the edit command
Assistant
The edit looks correct. Now let me verify the
appendObjectHeadersmethod has the right signature. Let me check the method without the booleanAssistant
Good, the
appendObjectHeaders(resp, obj, overrides)signature exists (line 1578). Now let me run the existing S3 integration tests to verify the fix works and doesn't break anythingAssistant
The HOME environment variable is not set. Let me set it and try again.
Assistant
98 tests ran, 1 failure. The failing test
copyObjectWithNonAsciiKeySucceedsseems unrelated to my change (it's about non-ASCII key handling). Let me check - this might be a pre-existing test failure.Assistant
Let me see the full test to understand the non-ASCII key issue:
Assistant
This failure (
copyObjectWithNonAsciiKeySucceeds) is clearly pre-existing and unrelated to my change (it's about non-ASCII key encoding in copy-source). Let me run just the range-related tests to confirm my fix worksAssistant
The tests are order-dependent (using
@Order). Let me run the full test suite and check specifically if the range tests passAssistant
The only failure is the pre-existing
copyObjectWithNonAsciiKeySucceedswhich is unrelated to my change. Let me verify this is pre-existing by temporarily reverting my change and running that specific testAssistant
Confirmed - the
copyObjectWithNonAsciiKeySucceedsfailure is pre-existing and unrelated. Let me restore my changesAssistant
Now let me check if there's a similar issue in the
copySourceRangehandling pathAssistant
Let me verify the fix compiles correctly
Assistant
Good, compilation succeeds. Now let me run the full test suite again and confirm only the pre-existing failure remains
Assistant
All range tests pass. Let me verify the specific range tests individually:
Assistant
Let me check the surefire report to confirm all range tests passed
Assistant
Let me check the surefire XML report for test
Assistant
Only the pre-existing
copyObjectWithNonAsciiKeySucceedsfailure (unrelated to my change). All 97 other tests pass, including all range-related tests.Let me review the final diff of my change
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.