Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· unknownHugging 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. Assistant

    I'll start by exploring the repository structure to understand the codebase and locate relevant files. Let's first check what's in the root directory.

  3. Assistant

    Let me look at the S3 controller file to find the range handling logic.

  4. Assistant

    Let me look at the S3Controller to find the handleRangeRequest method.

  5. Assistant

    Let me open the S3Controller.java file and look at the handleRangeRequest method.

  6. Assistant

    Let me scroll to the handleRangeRequest method to see the implementation.

  7. Assistant

    Now I understand the issue. Let me trace through the logic for an empty object (totalSize = 0) with bytes=-1:

    • suffix = 1
    • start = Math.max(0, 0 - 1) = 0
    • end = 0 - 1 = -1
    • Then start >= totalSize (0 >= 0) is true → returns 416

    But AWS returns a 200 with an empty body for this case. Let me also check what tests exist for range handling.

  8. Assistant

    Let me check the S3IntegrationTest to see if there are any range-related tests.

  9. Assistant

    Let me look at the test setup to understand how they create test objects.

  10. Assistant

    Let me look at the specific range test to understand what kind of objects they're testing with.

  11. Assistant

    Now I understand the issue completely. For an empty object (0 bytes) with a suffix range like bytes=-1:

    • start = Math.max(0, 0 - 1) = 0
    • end = 0 - 1 = -1
    • The check start > end (0 > -1) is true → returns 416

    According to AWS S3 behavior, when you request a suffix range and the object is smaller than the suffix length, the entire object should be returned with a 200 OK. For an empty object, that means returning an empty body with 200.

    Let me also check how the getObject method handles the Range header to understand the full flow:

  12. Assistant

    Now I have a clear understanding of the issue. Let me implement the fix. The fix should handle the case where totalSize == 0 for a suffix range request - in that case, we should return the entire empty object with a 200 OK response.

  13. Assistant

    Let me use the edit command instead.

  14. Assistant

    Now I understand the issue. Let me trace through the logic for bytes=-1 on an empty object:

    • totalSize = 0, suffix = 1
    • start = Math.max(0, 0 - 1) = 0
    • end = 0 - 1 = -1
    • Then at line 644: start >= totalSize (0 >= 0) is true → returns 416

    According to AWS S3 behavior, when you request a suffix range like bytes=-N and the object is smaller than N bytes, the entire object is returned. For an empty object, this means returning a 200 OK with an empty body.

    Let me fix this by adding a check for empty objects in the suffix range handling:

  15. Assistant

    Now I need to add the buildFullObjectResponse helper method. Let me add it after the invalidRangeResponse method:

  16. Assistant

    I see the closing brace of invalidRangeResponse was removed. Let me fix that:

  17. Assistant

    I see there's a duplicate method declaration. Let me fix that:

  18. Assistant

    Good. Let me add a blank line before the @HEAD annotation for readability:

  19. Assistant

    Good. Let me verify the final state of the modified section:

  20. Assistant

    Now let me check if the build tool is available and run the existing tests to make sure nothing is broken:

  21. Assistant

    Let me run the S3 integration tests to make sure existing tests pass:

  22. Assistant

    The HOME parameter is not set. Let me try with HOME set.

  23. Assistant

    Let me check if HOME is set.

  24. Assistant

    HOME is not set. Let me set it manually.

  25. Assistant

    The only failure is copyObjectWithNonAsciiKeySucceeds which is a pre-existing issue unrelated to my change. Let me run just the range-related tests to verify:

  26. Assistant

    The tests use @Order annotations and depend on setup from earlier tests. The getObjectWithFullRange test failed because it got 404 (bucket/object not set up). Let me run the full test class:

  27. Assistant

    Good - only 1 failure out of 98 tests, and it's the pre-existing copyObjectWithNonAsciiKeySucceeds test that's unrelated to my change. All range tests passed.

    Let me verify the diff of my changes:

  28. Assistant

    The diff looks clean. Let me also check if there are any tests specifically for empty object range requests:

  29. Assistant

    Good. Let me verify the appendObjectHeaders method signature to make sure my helper method is correct:

  30. Assistant

    Good - the appendObjectHeaders(resp, obj, overrides) call uses the 3-parameter overload which delegates to the 4-parameter version with includeChecksum=true. This is correct for a full object response.

    Let me also check if there are any unit tests for the S3Service that might test range handling:

  31. Assistant

    Now let me also verify there's no issue with the existing appendObjectHeaders overloads. Let me look at the method signature:

  32. Assistant

    Everything looks good. Let me run the S3ServiceTest to make sure I haven't broken anything:

  33. Assistant

    Let me check which test failed.

  34. Assistant

    The only failure in S3ServiceTest is copyObjectWithNonASCIIKey - a pre-existing unrelated issue (locale/charset problem). Not related to my change.

    Let me verify the complete diff one final time:

  35. Assistant

    Now let me review the complete diff one final time and go through the checklist:

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