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 implementation and its tests. Then I’ll reproduce or add a temporary focused check, make the smallest behavioral fix for empty-object suffix ranges, run relevant tests, and review the diff before submission.
- Assistant
The relevant logic is in
S3Controller.handleRangeRequest, and existing integration tests already cover normal suffix and invalid ranges. I’ll inspect that method plus the object response construction to determine the correct successful response metadata for a zero-byte suffix request, then run the focused S3 tests. - Assistant
The failure is isolated to suffix parsing: for a zero-length object it derives
(start,end)=(0,-1)and then rejects it. A suffix request cannot identify any actual byte in an empty representation, so the safest successful S3-compatible behavior is to return the object’s normal empty success response (status 200), rather than inventing an invalidContent-Rangesuch as0--1/0. I’ll add that narrow special case and preserve the object metadata/version/override headers. - Assistant
The first edit attempt could not run because this environment lacks
python3; no files were changed. I’ll apply the same targeted change using the available patch tooling, then compile and run the S3 test class. - Assistant
The source now has the intended branch and the missing
startassignment in the non-suffix path was preserved/restored after the line-based edit. Maven’s wrapper stopped before compilation becauseHOMEis unset in this shell, so I’ll rerun with a temporaryHOMEand then execute the focused S3 integration test target if the build setup permits it. - Assistant
Compilation succeeds. The S3 integration suite ran 98 tests; the only failure is the pre-existing
copyObjectWithNonAsciiKeySucceedsfailure (the log shows an unrelatedInvalidKey400), while the range tests passed. I’ll run the existing suffix-range test alone as an additional focused check and inspect the final diff/status. - Assistant
The focused test cannot run standalone because its ordered setup tests are skipped, so the fixture bucket/object does not exist; this is an infrastructure/test-selection limitation, not a regression. The full S3 class did execute the existing range tests successfully. The final change is limited to handling
bytes=-Nwhendata.length == 0, returning the same successful empty-object response headers as an un-ranged GET; malformed/zero suffixes and all non-empty range behavior remain unchanged.git diff --checkis clean and compilation passed.Checklist:
- Reproduced the reported failure path conceptually from the range logic; the full integration run also exercised existing range behavior.
- Confirmed the fix compiles and preserves the existing range tests; the new empty-object path is directly guarded.
- Considered edge cases: only positive suffixes on zero-byte objects are special-cased; malformed, zero, non-suffix, and non-empty requests retain prior validation.
- Ran affected existing tests; the S3 suite had one unrelated pre-existing non-ASCII-key failure, while range tests passed. The isolated range test was not runnable without ordered setup.
I’m submitting the single source change now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.