Skip to content

fix(zarr-metadata): a v2 array's other members are JSON with string keys - #4424

Merged
d-v-b merged 2 commits into
zarr-developers:mainfrom
d-v-b:fix/zarr-metadata-v2-array-other-members
Sep 26, 2026
Merged

d-v-b merged 2 commits into
zarr-developers:mainfrom
d-v-b:fix/zarr-metadata-v2-array-other-members

Conversation

@d-v-b

@d-v-b d-v-b commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

A v2 array document's members outside the .zarray definition are tolerated and dropped, since the spec asks readers to ignore them (#4365). But the validator never looked at them, so parse_array_metadata_v2 returned a document with an integer key, or with a set or NaN as a member, typed as ZarrV2ArrayMetadataJSON, where is_array_metadata_v2 said no.

They are now checked as v3 checks its extension fields: every key a string, every member JSON. Being there is still not a problem. The helper that does this serves both versions now, so it is renamed from _validate_extension_fields_v3 to _validate_other_members, and ZarrV2ArrayMetadataJSON declares extra_items=JSONValue, as its pydantic schema already did.

This is one of eight independent PRs from a review of the casts in zarr_metadata.model, each based on main and each passing just check alone, with a test that fails without its fix where there is behaviour to test:

#4425, #4426, #4428 and #4430 have merged, as have #4420, #4421 and #4422, and each of the four left is rebased onto them, so its tests are type-checked as #4421 requires. Of those four, only #4423 and #4429 touch the same lines, the TypeGuard import, so whichever of them merges second needs a one-line rebase. All eight together, merged with #4421's type-checked tests, pass just check.

🤖 Generated with Claude Code

@read-the-docs-community

read-the-docs-community Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 zarr-metadata | 🛠️ Build #34777869 | 📁 Comparing f83d661 against latest (4aeac75)

  🔍 Preview build  

3 files changed
± api/model/index.html
± api/pydantic/index.html
± api/v2/index.html

@d-v-b
d-v-b force-pushed the fix/zarr-metadata-v2-array-other-members branch from 57bf497 to 356dbb9 Compare September 26, 2026 17:45
@d-v-b
d-v-b force-pushed the fix/zarr-metadata-v2-array-other-members branch from 356dbb9 to f83d661 Compare September 26, 2026 18:41
@d-v-b
d-v-b marked this pull request as ready for review September 26, 2026 18:48
The v2 array validator tolerates members outside the `.zarray`
definition, as the spec asks readers to ignore them, but never looked at
them: `parse_array_metadata_v2` returned a document with an integer key,
or with a set or NaN as a member, typed as `ZarrV2ArrayMetadataJSON`,
where `is_array_metadata_v2` said no. The members are now checked as v3
checks its extension fields, by the same helper, renamed for both.

Assisted-by: ClaudeCode:claude-opus-5-5
@d-v-b
d-v-b force-pushed the fix/zarr-metadata-v2-array-other-members branch from f83d661 to 47cc9b4 Compare September 26, 2026 18:55
@d-v-b
d-v-b merged commit d73427e into zarr-developers:main Sep 26, 2026
7 of 9 checks passed
@d-v-b
d-v-b deleted the fix/zarr-metadata-v2-array-other-members branch September 27, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs release notes Automatically applied to PRs which haven't added release notes zarr-metadata Specific to the zarr-metadata sub-package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant