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:
software.amazon.awssdk.services.s3.model.S3Exception: The requested range is not satisfiable. (Service: S3, Status Code: 416)Reproduction
# 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 usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly 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 suffix path, implement the narrow fix, run affected tests, and review the diff before submitting.
- Assistant
The range logic is in
S3Controller. I’ll inspect the full method and object response construction to determine the correct zero-byte response semantics, especially headers and whether the existing no-range path can be reused safely. - Assistant
The failure is exactly the described
start=0, end=-1validation fortotalSize == 0. For a valid positive suffix on an existing empty object, the safest compatibility behavior is an empty successful response carrying the object metadata andContent-Length: 0; malformed/zero suffixes should remain416. I’ll factor the response construction so this special case preserves the same headers and overrides as normal GET, without changing non-empty range behavior. - Assistant
The first edit command could not run because this environment lacks
python3, so no files were changed. I’ll apply the same small refactor using an available shell tool, then compile and run the S3 integration tests. - Assistant
The source change is applied and
git diff --checkpasses. Maven wrapper failed before Maven started becauseHOMEis unset in the shell; I’ll rerun with a temporaryHOMEvalue, then inspect status and the relevant behavior if the integration suite is unavailable. - Assistant
Compilation succeeded. The S3 integration suite ran 98 tests; all range tests and the rest passed, with one unrelated pre-existing failure (
copyObjectWithNonAsciiKeySucceeds, 400 on invalid key). I’ll run only the range-focused tests and verify the final diff/status. - Assistant
The focused test invocation is not valid for this suite because filtering individual methods skips the class setup that creates
test-bucket, so its failures are all unrelated404 NoSuchBucket. The full suite did execute the range tests successfully; only the unrelated non-ASCII copy test failed. The final change is limited toS3Controller, and malformed suffixes remain rejected while positive suffixes on non-empty objects retain206behavior. I’ll do one final diff review and submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.