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
Interface
No new interfaces are introduced.
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 usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /floci, current file: none) bash-$
- Floci version / image tag:
Assistant
I'll start by exploring the repository structure to understand the codebase.
Assistant
Let me find the S3Controller and the handleRangeRequest method.
Assistant
Now I understand the structure. Let me look at the existing tests for range requests to understand the expected behavior.
Assistant
Let me look at the test setup to understand the object that's being used, and check for any empty object setup.
Assistant
Let me view the rest of the range tests.
Assistant
Let me look at the compatibility tests directory to understand how S3 range behavior is tested there.
Assistant
Let me look at the test class header to understand the testing framework used.
Assistant
Let me look at the
appendObjectHeadersmethod and its overloads to understand the checksum behavior.Assistant
Now let me reproduce the issue first. Let me check how to run a single test and verify the build works.
Assistant
Let me check the build setup and try running an existing range test to confirm the environment works.
Assistant
Let me create a temporary reproduction test to confirm the bug.
Assistant
I've confirmed the bug — the suffix range request on an empty object returns 416. Now let me apply the fix.
Assistant
I've confirmed the bug. Now let me apply the fix in
handleRangeRequestto handle empty objects.Assistant
Let me use the
editcommand instead.Assistant
The fix is applied. Now let me run the reproduction test again to confirm the fix.
Assistant
The fix works. Let me expand the temporary test to verify edge cases — that valid ranges on empty objects succeed, malformed ranges still return 416, and the suffix-range normalization still works for non-empty objects.
Assistant
The RestAssured
headermatcher syntax doesn't compile. Let me simplify that assertion.Assistant
All edge cases pass. Now let me run the full existing
S3IntegrationTestto ensure I didn't break anything.Assistant
Let me check whether this
copyObjectWithNonAsciiKeySucceedsfailure is pre-existing (unrelated to my change). Let me look at the test and run it in isolation.Assistant
This failure is at line 372 (PUT of a non-ASCII key), which is unrelated to my
handleRangeRequestchange. Let me verify it's pre-existing by checking against the original code usinggit stash.Assistant
The test failed on the original code too, confirming it's pre-existing. But running a single test in isolation may behave differently. Let me run the full
S3IntegrationTeston the original code (with my change stashed) to confirmcopyObjectWithNonAsciiKeySucceedsfails there too.Assistant
Confirmed —
copyObjectWithNonAsciiKeySucceedsfails identically on the original code (same line 372, 1 failure of 98). This is a pre-existing failure unrelated to my change (it's about non-ASCII key handling in PUT, not range requests). My change introduces zero new failures.Let me also verify the copy-source-range path (used by
CopyObjectwithx-amz-copy-source-range) isn't affected, since there's separate range logic there. Let me check it.Assistant
The copy-source-range logic lives in
S3Service.java(a separate method forUploadPartCopy), not inhandleRangeRequest, so it's unaffected. Let me run the multipart S3 test to be thorough.Assistant
Multipart tests pass. Let me also run the presigned URL tests since they exercise the same GetObject endpoint.
Assistant
All S3 tests pass (except the pre-existing unrelated non-ASCII failure). Now let me remove the temporary reproduction test file before submitting.
Assistant
Let me review the final diff to confirm the change is clean.
Assistant
The diff is clean and minimal. Let me view the complete updated method one final time to confirm correctness.
Assistant
The fix is complete and correct. Let me do a final verification that no temporary files remain in the repo and only the intended change is present.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →