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 first locate the S3 range handling code and its existing tests, then reproduce the empty-object suffix-range behavior at the unit level before making the smallest compatible fix. Afterward I’ll run focused and broader relevant tests and inspect the final diff.
- Assistant
The handler is centralized in
S3Controller. I’ll inspect its surrounding response logic and search S3 tests for range coverage so the fix preserves status/header semantics and can be verified through the project’s established test style. - Assistant
The failure is confirmed directly from the control flow: for
bytes=-1and zero bytes, parsing yieldsstart=0,end=-1, then the validation returns 416. A partial response cannot express an empty HTTP byte interval (Content-Range: bytes 0--1/0would be invalid), so the compatible behavior should be a normal successful empty-object response (200, length 0), effectively ignoring this satisfiable-by-empty suffix request. I’ll examine test fixtures and project history/style before implementing that special case without weakening invalid ranges such asbytes=-0, malformed ranges, or explicitbytes=0-. - Assistant
Existing tests establish that malformed and unsatisfiable nonempty ranges remain 416 and successful ranges omit whole-object checksums. I’ll run the focused integration class unchanged as a baseline, then extract the existing full-object response construction into a helper and invoke it only for a valid positive suffix range on an empty object. This ensures the empty response retains ordinary GET metadata/checksum/version headers and avoids inventing an invalid 206
Content-Range. - Assistant
The baseline test did not start because the environment has no
HOME, which Maven Wrapper requires; this is infrastructure rather than a code failure. I’ll rerun with a temporary validHOMEenvironment variable. - Assistant
The baseline ran 98 tests; all range tests passed, while one unrelated existing non-ASCII-key test failed before any changes (
copyObjectWithNonAsciiKeySucceeds, expected 200 but got 400). I’ll now apply the helper extraction and suffix-empty special case. Validity checks stay before the special case, sobytes=-0,bytes=-, and nonnumeric suffixes still return 416. - Assistant
Python is unavailable in this image, so no file was changed. I’ll use the repository editor commands instead, first replacing the duplicated response block, then inserting the helper and special case with explicit line-based edits.
- Assistant
I have the exact line positions. I’ll perform the three edits atomically enough to keep the file compilable: replace lines 597–607 with the helper call, insert the helper before range handling, and add the zero-size return after positive-suffix validation.
- Assistant
The extraction is correct and introduces no duplicate method. I’ll now insert the behavioral fix immediately after
suffix > 0is established. A short comment will document why the response is 200 rather than an impossible empty 206 range. - Assistant
The diff now cleanly limits changed behavior to valid suffix requests against zero-byte data; explicit/open-ended ranges on empty data still follow existing 416 validation. I’ll compile/package without tests first, then launch the built service briefly and reproduce the issue over HTTP with
curl: create a bucket, upload an empty object, requestRange: bytes=-1, and also probe invalid/explicit edge cases. No test files will be added or modified. - Assistant
Compilation/package passes and only the intended source file is modified. I’ll now perform the end-to-end reproduction against the packaged application, capturing status, headers, and body size for the fixed request plus
bytes=-0andbytes=0-controls. - Assistant
The live reproduction now succeeds exactly as required:
bytes=-1returns 200 with a zero-byte body,Content-Length: 0, and normal object headers. Controls confirm malformed zero suffix and explicit unsatisfiable range remain 416. I’ll run the existing S3 range tests selectively (including their bucket/object setup) to avoid the unrelated baseline non-ASCII failure while validating all established range behavior. - Assistant
All selected existing range tests pass. The DNS warning suggests the packaged-process cleanup may have left a child or another Java process bound to port 53 despite the shell trap, so I’ll check and clean only the reproduction process if needed, then review status/diff and optionally run a final compile check.
- Assistant
The packaged JVM did remain alive because the environment detached the background job before the trap ran; I’ll terminate that exact PID and verify cleanup. The final diff is whitespace-clean and contains only the controller change.
- Assistant
Cleanup is complete. Before submitting, I’ll inspect repository-specific guidance and the final diff one last time to ensure no convention or required validation was missed.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.