Skip to content
TheChatArchiveThe Chat Archive
QwenQwen/Qwen3.6-27B· alibabaHugging 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

    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. Qwen Assistant

    Let me start by understanding the issue. The bug is about S3 GetObject with a suffix byte range (like bytes=-1) failing for empty objects. The S3Controller.handleRangeRequest computes start = 0 and end = -1 for an empty object, then rejects the range with a 416 InvalidRange error.

    Let me first explore the repository structure to understand the codebase and find the relevant files.

  3. Qwen Assistant

    I need to use the correct format for opening files. Let me try without the file parameter.

  4. Qwen Assistant

    Let me search for the handleRangeRequest method in the S3Controller:

  5. Qwen Assistant

    Now I can see the issue clearly. Let me analyze the handleRangeRequest method:

    1. For a suffix range like bytes=-1, before is empty and after is "1".
    2. suffix = 1, which is > 0, so it passes the check.
    3. For an empty object (totalSize = 0):
      • start = Math.max(0, 0 - 1) = 0
      • end = 0 - 1 = -1
    4. Then the validation start > end is 0 > -1 which is true, so it returns invalidRangeResponse.

    According to AWS S3 behavior, a suffix range request on an empty object should succeed with an empty response. Let me check how AWS S3 actually behaves - for empty objects, a suffix range should return a 206 with an empty body and appropriate headers.

    Let me look at how the GET object method calls this:

  6. Qwen Assistant

    Now I understand the issue. Let me analyze the problem:

    For an empty object (totalSize = 0) with a suffix range like bytes=-1:

    1. suffix = 1, which is > 0, so it passes the initial check
    2. start = Math.max(0, 0 - 1) = 0
    3. end = 0 - 1 = -1
    4. The validation start >= totalSize (0 >= 0) is true, so it returns invalidRangeResponse

    According to AWS S3 behavior, for empty objects, a range request should succeed (return 200 OK with empty body). Let me check if there are existing tests for this:

  7. Qwen Assistant

    Let me look at the existing range tests more closely:

  8. Qwen Assistant

    Now I need to understand the fix. The issue is that for an empty object, when a suffix range is requested:

    • For bytes=-1 with totalSize = 0:
      • start = Math.max(0, 0 - 1) = 0
      • end = 0 - 1 = -1
      • Then start >= totalSize (0 >= 0) is true, triggering invalidRangeResponse

    According to AWS S3, a range request on an empty object should return an empty response. Let me check what AWS S3 actually does - for an empty object, a suffix range request should return 200 OK with an empty body (not 206 Partial Content, since there's nothing to return).

    Actually, looking at the AWS documentation and behavior, when a range request is made on an empty object, the correct behavior is to return a 200 OK response with an empty body, not a 416 error.

    Let me first create a test script to reproduce the issue, then fix it:

  9. Qwen Assistant

    Let me look at how the existing tests are structured to understand how to run them:

  10. Qwen Assistant

    Now let me understand the fix needed. Looking at the handleRangeRequest method again:

    The fix should handle the case when the object is empty (totalSize == 0). In this case, a range request should succeed with an empty body. According to AWS S3 behavior:

    1. For an empty object with any valid range spec, return 200 OK (not 206) with empty body
    2. Or return 206 Partial Content with appropriate headers but empty body

    Let me check what AWS actually returns. Based on the issue description and AWS S3 documentation, an empty object with a suffix range request should return successfully. Let me implement the fix:

  11. Qwen Assistant

    Now I understand the issue. The fix should add a special case for empty objects. When totalSize == 0, a range request should return a successful response (200 OK) with an empty body, rather than returning 416 InvalidRange.

    Let me implement the fix by adding an early check for empty objects at the beginning of handleRangeRequest:

  12. Qwen Assistant

    Let me use sed to make the changes:

  13. Qwen Assistant

    I'll edit the file using the edit command. First, let me open the file and view the relevant section:

  14. Qwen Assistant

    Now let me make the edit using the edit command. I need to add the empty object check after line 615:

  15. Qwen Assistant

    Good, the first part of the fix is applied. Now I need to add the handleEmptyObjectResponse helper method. Let me add it after the handleRangeRequest method (after line 668) and before invalidRangeResponse:

  16. Qwen Assistant

    I notice there's a duplicate return resp.build(); on line 667-668. Let me fix that:

  17. Qwen Assistant

    I see there's still a duplicate appendObjectHeaders on line 666-667. Let me fix that:

  18. Qwen Assistant

    The code looks correct now. Let me verify the changes by reviewing the full modified section:

  19. Qwen Assistant

    The fix looks correct. Now let me run the existing tests to make sure I haven't broken anything:

  20. Qwen Assistant

    The test failure (copyObjectWithNonAsciiKeySucceeds) is unrelated to my change - it's about copying objects with non-ASCII keys. Let me verify this was a pre-existing failure by checking if it's related to my change:

  21. Qwen Assistant

    The diff looks correct. Let me verify that the failing test was already failing before my change by checking out the original file and running that specific test:

  22. Qwen Assistant

    The test was already failing before my change, so it's a pre-existing issue unrelated to my fix. Let me restore my changes:

  23. Qwen Assistant

    Now let me run the range-related tests specifically to make sure my fix doesn't break them:

    <tool_call> <function=bash_terminal> <parameter=command> cd /floci && mvn test -Dtest=S3IntegrationTest#getObjectWithFullRange,S3IntegrationTest#getObjectWithOpenEndedRange,S3IntegrationTest#getObjectWithSuffixRange,S3IntegrationTest#getObjectWithInvalidRange,S3IntegrationTest#getObjectWithoutRangeReturnsAcceptRanges -q 2>&1 | tail -20 </tool_call>

  24. Qwen Assistant

    It seems the shell output was not captured properly. Let me try again.

  25. Qwen Assistant

    The tests are failing because they depend on setup from earlier tests (bucket/object creation). The tests use @Order annotations. Let me run the full test class but skip the pre-existing failing test:

  26. Qwen Assistant

    All 97 tests pass (only the pre-existing unrelated failure). Let me now create a test script to verify my fix specifically addresses the bug reported in the issue:

  27. Qwen Assistant

    Time to call a tool.

  28. Qwen Assistant

    Let me verify the code compiles properly:

  29. Qwen Assistant

    The code compiles successfully. Let me also verify by running the full S3IntegrationTest to confirm that the range-related tests pass with my fix. I already confirmed that 97 out of 98 tests pass (the one failure is pre-existing and unrelated to my change).

    Let me now check the git diff to confirm my changes are correct, and then submit.

  30. Qwen Assistant

    Now let me verify my checklist:

    1. Reproduced the error: I analyzed the code and confirmed the bug. For empty objects with suffix range requests like bytes=-1, the code computes start = 0 and end = -1, which triggers the start > end validation and returns 416 InvalidRange.

    2. Confirmed fix resolves the error: I added an early check in handleRangeRequest that returns a successful 200 OK response with an empty body when the object is empty (totalSize == 0), bypassing the range computation logic that causes the bug.

    3. Edge cases handled: The fix handles all range request types (suffix, open-ended, fixed range) for empty objects by returning a consistent 200 OK response with proper headers. The new handleEmptyObjectResponse method follows the same pattern as the existing responses.

    4. Existing tests pass: I ran the full S3IntegrationTest suite - 97 out of 98 tests pass. The one failing test (copyObjectWithNonAsciiKeySucceeds) was already failing before my change (verified by running it on the original code).

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