Repository navigation
fix: tighten array metadata field validation - #4494
Open
barlowa124 wants to merge 2 commits into
Open
barlowa124 wants to merge 2 commits into
barlowa124 wants to merge 2 commits into
Conversation
Four metadata fields accepted out-of-contract JSON: - shape accepted booleans ([true] read as (1,)); document shape fields now reject them via parse_shapelike(reject_bool=True). Stored chunks/chunk_shape fields keep the lenient default since older versions wrote true there and repair tests codify reading them. - attributes accepted a list; it now requires a dict with string keys, matching the check GroupMetadata already applies. - dimension_names accepted a bare string, iterating it into characters; strings and bytes are excluded before the element check. - storage_transformers accepted a dict, iterating it into keys; mappings are excluded. Refs zarr-developers#4453 Generated with Devin Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4494 +/- ##
=======================================
Coverage 94.69% 94.70%
=======================================
Files 94 94
Lines 13606 13624 +18
=======================================
+ Hits 12884 12902 +18
Misses 722 722
🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Summary
Four array metadata fields accepted JSON outside the spec contract.
shape: [true]parsed as(1,)becauseboolsubclassesint. Documentshapefields now reject booleans throughparse_shapelike(..., reject_bool=True), while storedchunks/chunk_shapefields keep the lenient default since old versions wrotetruethere and repair tests codify reading them.attributes: []parsed as{}.parse_attributesnow requires a dict with string keys, matching the checkGroupMetadataalready applies.dimension_names: "xy"parsed as("x", "y")because a bare string is iterable. Strings and bytes are excluded before the element check.storage_transformers: {"name": ...}parsed as a tuple of keys. Mappings are excluded from the iterable check.Refs #4453, fifth checklist item.
For reviewers
The
parse_shapelikesignature gains a keyword-onlyreject_boolflag, with the lenient default preserving the repair path for stored chunk sizes. Worth a second look:attributes: nullstill parses to{}, matching the group's handling of missing attributes.Author attestation
TODO
docs/user-guide/*.mdchanges/