Repository navigation
Require a writable store to build a SwapWriteStore - #411
Merged
Merged
Conversation
NewSwapWriteStore took a plain Store while StoreChunk asserted the wrapped store was a WriteStore. Building one around a store that isn't compiled and constructed without complaint, then panicked on the first write: panic: interface conversion: desync.roStore is not desync.WriteStore Taking a WriteStore makes that a compile error. Swap already refuses to replace a writable store with one that isn't, so the assertion in StoreChunk now holds by construction. The command line already checked the store was writable before wrapping it, so this was only reachable through the library.
folbricht
force-pushed
the
swapstore-writable
branch
from
September 2, 2026 14:43
07e0739 to
06e51cb
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.
NewSwapWriteStoreaccepted a plainStorewhileStoreChunkasserted the wrapped store was aWriteStore. Handing it one that isn't compiled fine, constructed without complaint, and then died on the first write:Taking a
WriteStoremakes that a compile error.Swapalready refuses to replace a writable store with one that isn't, so between the two the assertion inStoreChunknow holds by construction, and it carries a comment saying so.chunk-serveralready checkeds.(desync.WriteStore)before wrapping, so this was never reachable from the command line — only through the library. It now passes the value the assertion produces instead of re-passing the interface.API change:
NewSwapWriteStore(Store)becomesNewSwapWriteStore(WriteStore). Any caller it breaks is a caller that would have panicked at runtime.There are no tests: the fix is that the bad call no longer compiles, and any test for it would have to bypass the constructor to reconstruct the state the change removes.