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 inspect the repository structure and locate the S3 range handling code and relevant tests. Then I’ll reproduce or reason through the empty-object path, implement the smallest compatibility fix, run targeted tests (plus any practical broader checks), and review the diff before submitting.
- Assistant
The range parser confirms the reported failure:
bytes=-1on a zero-length object becomesstart=0, end=-1, and the shared satisfiability check returns 416. I’ll preserve malformed and ordinary unsatisfiable ranges, while treating only a valid positive suffix range on an empty object as a successful empty GET response. Because there is no representable byte interval (and therefore no validContent-Range), the response should be a normal 200 with zero content length and the usual object metadata. - Assistant
The first edit attempt was blocked by the environment lacking
python3; no repository files were changed. I’ll apply the same narrowly scoped change using the available patch tooling, then compile and run the S3 tests. - Assistant
Compilation succeeded. The full
S3IntegrationTestrun reached 98 tests with only one pre-existing unrelated failure (copyObjectWithNonAsciiKeySucceeds, invalid key handling); the range behavior itself was exercised in that run. A second attempt to select only range methods failed because those methods depend on ordered setup performed by the full class, not because of the change. I’ll do a final source/diff review and verify no generated or unintended files are present. - Assistant
Final review shows one intentional source change, clean whitespace, and no generated artifacts. The fix is limited to valid positive suffix ranges on zero-byte objects;
bytes=-, nonnumeric ranges, zero/negative suffixes, and ordinary ranges retain their existing validation. The implementation also preserves content type, length, ETag, modification time, version ID, metadata/checksum/lock headers, andAccept-Rangesconsistently with a normal GET.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.