Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION [BUG] S3 GetObject suffix range fails for empty objects Service S3 AWS…

  1. User

    ISSUE DESCRIPTION

    [BUG] S3 GetObject suffix range fails for empty objects

    Service

    S3

    AWS API Action

    GetObject with the Range header set to a suffix byte range, for example bytes=-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 InvalidRange for the same request because S3Controller.handleRangeRequest computes start = 0 and end = -1 for 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-output
    

    Environment

    • 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 using git reset --hard command. Additionally, you can use git stash and git stash pop 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 submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. Claude Assistant

    Now let's build and test.

  3. Claude Assistant

    Compiled successfully. Now let's run the existing S3 range-related tests to make sure nothing broke.

  4. Claude Assistant

    These tests don't cover empty objects, so unaffected. Let's run the full test suite for S3IntegrationTest to double check.

  5. Claude Assistant

    Confirmed: this failure pre-exists and is unrelated to our change (environment/locale issue). Good, our change doesn't cause any new test failures.

    Now let's write a quick reproduction script to verify the fix works using a live server via curl.

  6. Claude Assistant

    Test passed (no failures reported, "BUILD SUCCESS" implied since exit shows nothing failing, bucket created and deleted cleanly). Let's confirm explicitly with a non-quiet run showing test summary.

  7. Claude Assistant

    The fix works. Now clean up the temporary test file and remove backup artifacts.

  8. Claude Assistant

    Now let's run the full existing S3IntegrationTest suite once more to confirm only the pre-existing unrelated failure remains and no new failures were introduced.

  9. Claude Assistant

    Same pre-existing failure only, confirmed unrelated to our fix (verified earlier it fails even without our change). Let's view the diff for final review.

  10. Claude Assistant

    This is a clean, minimal fix. Let me review the checklist items once more and finalize.

  11. Claude Assistant

    Let's explicitly confirm the bug reproduction by temporarily reverting the fix and re-running the temp test to see the 416 failure, then restore the fix.

  12. Claude Assistant

    Confirmed reproduction of the exact 416 error described in the issue. Now restore the fix and remove the temp test.

  13. Claude Assistant

    Fix restored. Let's do a final compile and full test run to be safe.

  14. Claude Assistant

    Only the pre-existing, unrelated failure remains (confirmed earlier to exist on the unmodified codebase too). No temp test files left in the repo, and the fix is compiled successfully.

  15. Claude Assistant

    I have completed the fix. Let me address the checklist explicitly before submitting:

    • If an error was reported in the issue description, I have successfully reproduced it. ✅ I reverted my fix temporarily and wrote a test that PUTs a 0-byte object then GETs it with Range: bytes=-1. It failed with Expected status code <200> but was <416>, exactly matching the 416 InvalidRange error described in the issue.

    • If an error was reported in the issue description, I have confirmed that my fix resolves the error. ✅ After restoring my fix (adding a special case in S3Controller.handleRangeRequest for totalSize == 0 that returns a normal 200 OK response with an empty body instead of computing an invalid start > end range and rejecting it with 416), the exact same test passed with status 200, Content-Length: 0, and empty body.

  16. Claude Assistant
    • I have thought about edge cases and made sure my fix handles them as well. ✅ The new totalSize == 0 branch is placed after all the existing syntax-validation logic (missing dash, empty suffix, non-numeric values, negative suffix, etc.), so malformed range headers against an empty object still correctly return 416 InvalidRange — only syntactically valid range requests (suffix ranges like the issue's bytes=-1, explicit ranges like bytes=0-5, and open-ended ranges like bytes=0-) now succeed with an empty body when the object has zero bytes, matching S3's real-world behavior of treating "no bytes to slice" as a satisfied read of the (empty) object. Non-empty objects are entirely unaffected since totalSize > 0 skips this new code path, preserving all pre-existing 206/416 behavior.

    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. ✅ Ran the full S3IntegrationTest suite (98 tests) both with and without my change. The only failure, copyObjectWithNonAsciiKeySucceeds, is pre-existing and unrelated (fails identically on the unmodified codebase per git stash verification — an environment/locale issue with non-ASCII URL encoding, not related to range handling). All range-related tests (getObjectWithFullRange, getObjectWithOpenEndedRange, getObjectWithSuffixRange, getObjectWithInvalidRange, all malformed-range tests, and the checksum-omission test) continue to pass unchanged.

    Also verified no leftover temporary test files or artifacts remain in the repo (git status shows only the intended S3Controller.java change).

  17. Claude Assistant

    Those are pre-existing files unrelated to my change (matched the "Temp" substring pattern in "Template"). No leftover temp files from my work. Everything is clean and the fix is complete and verified.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.