fix: refuse writes to a store zarr-python opened read-only - #190
Open
selmanozleyen wants to merge 1 commit into
Open
fix: refuse writes to a store zarr-python opened read-only#190selmanozleyen wants to merge 1 commit into
selmanozleyen wants to merge 1 commit into
Conversation
zarr-python enforces read-only in the store itself -- `Store._check_writable`, reached from the concrete store's `_set`. This pipeline never gets there: it is handed a `StoreConfig` and builds its own Rust store, writable whatever mode the array was opened in, so a write to a `mode="r"` array succeeds here and raises through the default pipeline. Silent divergence, and silent data loss for anyone relying on the mode. The flag has to be carried from Python because nothing on the Rust side can infer it: the mode is zarr-python's, not the store's. One guard, at the only entry point Python can write through. `store_chunk_bytes` and `store_chunk_subset_bytes` are reached only from it. The tests open STRICT. zarr's own refusal message is byte-identical to the guard's, so with a fallback available they would pass whether the guard fired or zarr-python served the write.
selmanozleyen
marked this pull request as ready for review
August 28, 2026 15:45
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.
Hi,
I'd like to propose some changes for the integer indexing case but because shard index caching depends on it and because it's also a nice thing to have in general I opened this PR. This enables us to be clear with the refusal of writing read only stores.
The flag has to be carried from Python because nothing on the Rust side can infer it: the mode is zarr-python's, not the store's. One guard, at the only entry point Python can write through.
store_chunk_bytesandstore_chunk_subset_bytesare reached only from it.