Repository navigation
fix(storage): make every ObjectStore answer a ranged read the same way - #50
Merged
Merged
Conversation
ObjectStore promises that a range extending past the end returns the available bytes rather than failing, and that a read of a missing key throws ObjectNotFoundException. FileObjectStore kept both promises; the other two did not, so the same call gave different answers depending on which implementation was configured. - S3ObjectStore let the server's 416 out as a raw S3Exception when the first byte lay at or past the object's end, and returned an empty stream for a zero-length read of a key that does not exist instead of reporting the wrong key. - InMemoryObjectStore accepted a negative offset or length, and computed its slice with offset + length, which overflows for a caller asking for everything from an offset with Long.MAX_VALUE. - Both now clamp in long arithmetic; S3ObjectStore sends an open-ended range where the last byte would overflow. Tests: ObjectStoreContractTest holds the interface's promises and runs against all three implementations, which is the only thing that keeps three backends honest about one interface. The S3 store runs against a real S3 server rather than a stub — what a server answers to an out-of-range read is exactly the thing a stub would have to assume, and that assumption was the bug. Reverting either fix turns the suite red: four cases for S3, three for the in-memory store. Also covers what each implementation promises alone: the file store's traversal guard, its scratch-then-move write, the upload sweep, and the S3 store's multipart boundary at PART_SIZE_BYTES. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
hendrikebbers
force-pushed
the
fix/storage-range-contract
branch
from
September 25, 2026 07:45
71655fd to
92a5e04
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ObjectStorepromises that a range extending past the end returns the available bytes rather than failing, and that reading a missing key throwsObjectNotFoundException.FileObjectStorekept both promises. The other two did not, so the same call gave different answers depending on which implementation was configured.The divergences
FileObjectStoreS3ObjectStoreInMemoryObjectStoreS3Exception(HTTP 416) ❌ObjectNotFoundException✅ObjectNotFoundException✅IllegalArgumentException✅IllegalArgumentException✅length = Long.MAX_VALUEAll four now agree. Both stores clamp in long arithmetic, and the S3 store sends an open-ended
bytes=offset-where the last byte would overflow.ObjectStoreContractTestThe fix on its own would not stop this happening again — a shared suite would.
ObjectStoreContractTestholds the interface's promises and runs against all three implementations, 22 cases each.The S3 store runs against a real S3 server (
adobe/s3mock), not a stub. What a server answers to an out-of-range read is exactly the thing a stub would have to assume, and that assumption is what was wrong in the first place. The client is built throughS3Clients.withoutChunkedEncoding, the same helper the auto-configuration uses, so the test can never pass against a more lenient client than an application gets.Each implementation also gets what only it promises: the file store's traversal guard (8 rejected key shapes), its scratch-then-move write and upload sweep; the S3 store's multipart boundary at exactly
PART_SIZE_BYTES, and a ranged read reaching across a part boundary.The tests were checked against the bug
Reverting each fix and re-running:
S3ObjectStore→rangeStartingAtTheEnd,rangeStartingPastTheEnd,zeroLengthOfAMissingKey,readToTheEndfailInMemoryObjectStore→negativeOffset,negativeLength,readToTheEndfailVerification
./mvnw -Pfull-build clean verify -Dmaven.javadoc.failOnWarnings=true— green across all twelve modules; 91 tests in the storage module.Docs
docs/releases/upgrade-to-1.5.mdgains the cross-backend guarantee under "What you get", and its maturity note is corrected — the implementations are covered now.docs/TODO.mddrops the two resolved items and records two that surfaced while fixing: the untested abort paths, andS3ObjectStorestill letting raw SDK exceptions escape where the package documentsObjectStoreException.🤖 Generated with Claude Code