Untitled conversation
- User
[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.
- Floci version / image tag:
- Assistant
Investigating S3 range handling for empty objects in the codebase.
- Assistant
Implementing the fix for empty-object suffix ranges, then verifying with a focused test.
- Assistant
Simplifying the fix: adjust suffix
endand validation instead of refactoring. - Assistant
Fix
handleRangeRequestinS3Controllertreated suffix ranges on zero-byte objects as invalid because it setend = totalSize - 1(−1) and then rejected the range whenstart >= totalSize(0 ≥ 0).Changes:
- For suffix ranges on empty objects, set
endto0instead of-1. - Only apply
start >= totalSizewhentotalSize > 0, so a valid empty suffix range (bytes=-1→start=0,end=0) is accepted and returns 206 with an empty body andContent-Range: bytes 0-0/0.
start = Math.max(0, totalSize - suffix); end = totalSize > 0 ? totalSize - 1 : 0; } else { start = Integer.parseInt(before); end = after.isEmpty() ? totalSize - 1 : Math.min(Integer.parseInt(after), totalSize - 1); } } catch (NumberFormatException e) { return invalidRangeResponse(totalSize); } if (start < 0 || start > end || (totalSize > 0 && start >= totalSize)) { return invalidRangeResponse(totalSize); } - For suffix ranges on empty objects, set
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.