Ignore v3 metadata members declaring must_understand: false - #94
Open
konstibob wants to merge 1 commit into
Open
Ignore v3 metadata members declaring must_understand: false#94konstibob wants to merge 1 commit into
konstibob wants to merge 1 commit into
Conversation
A Zarr v3 writer may add members to a metadata document that a reader does
not know about. When such a member is a JSON object carrying
"must_understand": false, the specification requires a reader to ignore it;
any other unknown member has to be rejected, because it may change how the
array is to be interpreted.
zarr-java rejected every unknown member instead, because the ObjectMapper in
v3.Node was built with Jackson's default FAIL_ON_UNKNOWN_PROPERTIES. Reading
a zarr.json written by a newer implementation therefore failed with an
UnrecognizedPropertyException on a member that was explicitly marked as safe
to skip.
Unknown members are now collected through a @JsonAnySetter creator parameter
and validated in ExtraFields, which mirrors zarr-python 3.1.6
(zarr/core/metadata/v3.py):
- a JSON object with "must_understand": false is ignored,
- anything else is rejected with a ZarrException,
- an extra field colliding with a member the document defines itself is
rejected.
Ignored members are kept on the metadata and written back out by a
@JsonAnyGetter, so that another implementation's extension survives a
metadata rewrite. ArrayMetadataBuilder.fromArrayMetadata and
Group.setAttributes carry them over, which covers resize, setAttributes and
updateAttributes.
must_understand deliberately does not apply to codec, chunk grid or chunk key
encoding names: a codec cannot be skipped and still leave the chunk bytes
decodable, so an unknown name there still fails.
Verified against zarr-python 3.1.6 in both directions: a document it writes
with an extra field now opens, and a document zarr-java rewrites is read back
by zarr-python with the field intact in its own extra_fields.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
A Zarr v3 writer may add members to a metadata document that a reader does not know about. When such a member is a JSON object carrying "must_understand": false, the specification requires a reader to ignore it; any other unknown member has to be rejected, because it may change how the array is to be interpreted.
Reading a zarr.json written by a newer implementation therefore failed with an UnrecognizedPropertyException on a member that was explicitly marked as safe to skip.
must_understand deliberately does not apply to codec, chunk grid or chunk key encoding names: a codec cannot be skipped and still leave the chunk bytes decodable, so an unknown name there still fails.
Verified against zarr-python 3.1.6 in both directions: a document it writes with an extra field now opens, and a document zarr-java rewrites is read back by zarr-python with the field intact in its own extra_fields.