fix(zarr-metadata): v2 array document is open and filters may be empty - #4365
Conversation
Two v2 structural rules were stricter than the spec, and the shared
conformance corpus (zarr-metadata.js, conformance/v2_array.json cases 5
and 8) has been updated first; this brings the reference implementation
back into agreement.
- Members outside the .zarray definition were rejected. The spec: "Other
keys SHOULD NOT be present within the metadata object and SHOULD be
ignored by implementations" — a recommendation, unlike .zgroup's
"Other keys MUST NOT be present". Extras are now tolerated by the
validator, dropped by the model, and permitted by the Pydantic schema
(the TypedDict is open, like the v3 one). The on-disk `.zarray` rule
that `attributes` belongs in `.zattrs` is unchanged.
- filters: [] was rejected ("expected at least one filter"). The spec:
"A list of JSON objects providing codec configurations, or null" — an
empty list is a list. The Pydantic schema's min_length is dropped.
Assisted-by: ClaudeCode:claude-fable-5-1
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-fable-5-1 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Documentation build overview
26 files changed ·
|
Documentation build overview
7 files changed ·
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4365 +/- ##
=======================================
Coverage 94.22% 94.22%
=======================================
Files 92 92
Lines 12942 12942
=======================================
Hits 12195 12195
Misses 747 747 🚀 New features to boost your workflow:
|
Assisted-by: ClaudeCode:claude-fable-5-1 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Every docstring or comment that cites the Zarr spec or a zarr-extensions README now carries a commit-pinned permalink with a line range (zarr-specs fc7dd9c; zarr-extensions 4da7b37, the registry commit the TypeScript port vendors). Unpinned zarr-extensions `tree/main` page links are pinned the same way. Three statements were wrong or stale and are corrected: - zstd: `checksum` was typed required "per the proposed specification" (zarr-specs PR #256, never merged). The published zarr-extensions entry makes it optional ("Should be omitted if false"; schema requires only `level`), so it is now `NotRequired[bool]`. - v3 consolidated metadata was described as "not a spec artifact"; since zarr-specs zarr-developers#373 the core spec names the field and fixes its envelope (core/index.rst L802-L816); the entry format remains a convention. - The v2 array `*Partial` docstring spoke of a "closed shape"; the array document is open (other keys SHOULD be ignored), unlike `.zgroup`. Assisted-by: ClaudeCode:claude-fable-5-1 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
🤖 AI text below 🤖 Added a docs commit that links every spec statement in While doing that, three statements turned out to be wrong or stale, corrected in the same commit — reviewers may want to look at these specifically:
|
This AI-authored PR brings
zarr-metadatacloser to the spec by allowingfilters: []and extra keys in.zarray(I didn't know the spec allowed this -- extra keys are forbidden from.zgroup)🤖 AI text below 🤖
Two structural rules in
zarr_metadata's v2 array validator are stricter than the v2 spec. The shared conformance corpus was updated first (d-v-b/zarr-metadata.js#2,conformance/v2_array.jsoncases 5 and 8), which turns this package's conformance run red (65/67) until it follows — this PR brings it back to 67/67.docs/v2/v2.0.rst).zarray.zgroupline 313: "Other keys MUST NOT be present"invalid_valueat the keyvalidate_array_metadata_v2, dropped by the model, allowed by the Pydantic schemafilters: []null" — no minimuminvalid_value"expected at least one filter"min_length=1dropped from the schema too)Changes
model/_validation.py: the v2 array validator no longer calls_unexpected_keys(the group validator still does) and no longer rejects an empty filter list._pydantic_schema.py:ZarrV2ArrayMetadataJSONbecomesextra_items=JSONValuelike the v3 TypedDict;ZarrV2FilterPipelineJSONlosesField(min_length=1).ZarrV2GroupMetadataJSONstaysclosed=True..zarrayrule infrom_key_valuethatattributesmust not appear there (it lives in.zattrs) — that's a different rule, and the test for it is now separate from the "other extras are ignored" test.test_v2_filters_may_be_empty,test_array_v2_ignores_unknown_document_member,test_v2_from_key_value_ignores_zarray_extra_members,test_v2_array_schema_allows_empty_filters,test_v2_array_schema_allows_unknown_document_members.The TypeScript port keeps the SHOULD NOT visible: its (TS-only) v2 semantic layer reports extra
.zarraymembers as advisories so consumers can surface them as warnings.Test plan
just testinpackages/zarr-metadata: 595 passedjust lintjust conformance <this checkout>: 67/67 (was 65/67 against the released package)🤖 Generated with Claude Code