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
I’ll first locate the S3 range handling code and its existing tests, then reproduce the empty-object suffix-range path at unit level before making a narrowly scoped fix. Afterward I’ll run the relevant test suite and inspect the final diff.
- Assistant
The implementation is in
S3Controller; I’ll inspect the surrounding response logic, range parser, and S3 tests to understand expected status/header behavior and identify whether empty ranges already have conventions elsewhere. - Assistant
The failure is confirmed directly from the code path: for
bytes=-1and zero bytes it computes(start, end) = (0, -1)and returns 416. An empty representation cannot have a validContent-Rangefor a 206 response, so the standards-compatible successful fallback is to ignore this otherwise valid suffix range and return the full zero-byte representation as 200. I’ll check project conventions/build settings and the full range test context, then refactor the normal-object response into a helper so the fallback preserves all normal metadata, version, overrides, and checksums without duplication. - Assistant
Malformed ranges must remain 416 even on empty objects, so the special case belongs only after successfully parsing a positive suffix length. I’ll add a shared full-object response helper, use it for ordinary GETs, and invoke it only for valid suffix ranges when
totalSize == 0; explicit/open-ended ranges against empty objects will retain existing 416 behavior. - Assistant
Python is not installed in the environment, so no source change was made. I’ll apply the same edits using the repository editor commands instead.
- Assistant
The line-number edits shifted after the first replacement and corrupted the adjacent
catchand range block. I caught this during immediate review. I’ll replace the entire affected GET/range section atomically with the intended complete implementation, including the missing helper, rather than attempting further incremental line edits. - Assistant
The repaired section is structurally correct and
git diff --checkpasses. The behavior now distinguishes valid positive suffixes from malformed/zero suffixes and preserves existing behavior for non-empty objects. I’ll compile and run the existingS3IntegrationTest, which exercises ordinary GET, valid ranges, and invalid ranges and will also verify the refactor did not alter those paths. - Assistant
The Maven wrapper did not start because this sandbox leaves
HOMEunset; this is an environment issue, not a compilation failure. I’ll rerun withHOME=/rootexplicitly set. - Assistant
Compilation succeeded. The 98-test S3 suite ran with all range/GET tests passing; its sole failure is an unrelated pre-existing non-ASCII key validation test (
InvalidKeyat setup), outside the changed code paths. To verify the reported scenario itself without modifying tests, I’ll package and launch Floci, create an empty object over HTTP, issueRange: bytes=-1, and assert status 200, zero body length, and no invalidContent-Range. - Assistant
The exact reproduction now succeeds: bucket/object creation returned 200,
bytes=-1returned 200 with a zero-byte body, and no impossibleContent-Rangewas emitted. I’ll perform targeted edge-case checks to ensure malformed suffixes and explicit ranges on empty objects still return 416, then review the final diff and repository status.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.