Skip to content

fix(indexing): validate index-array bounds during JSON loading - #4347

Merged
d-v-b merged 17 commits into
zarr-developers:mainfrom
d-v-b:codex/indexing-wire-bounds
Sep 14, 2026
Merged

fix(indexing): validate index-array bounds during JSON loading#4347
d-v-b merged 17 commits into
zarr-developers:mainfrom
d-v-b:codex/indexing-wire-bounds

Conversation

@d-v-b

@d-v-b d-v-b commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

This AI-authored zarr-indexing PR ensures that we respect bounded coordinate domains.

🤖 AI text below 🤖

JSON loading must enforce index_array_bounds instead of ignoring them. Both IndexTransform.from_json and output_index_map_from_json now validate every supplied raw index value against the inclusive interval before offset, stride, or map simplification.

Valid finite and one-sided bounds are accepted. Values outside the interval raise NdselError("invalid_json", ...) immediately, including for singleton arrays and zero-stride maps. Empty arrays satisfy any well-formed, ordered interval. Both loaders validate the interval's syntax and ordering, sharing the message layer's validator. Omitted or explicitly unbounded intervals avoid an additional value scan.

The validation is eager: a map containing an invalid entry is rejected even if a subsequent selection would avoid that position. Once the index coordinates have been validated and stored immutably, bounds need not be carried through later map operations. Serialization emits unconstrained bounds for non-degenerate maps; message normalization preserves the supplied bounds. This does not provide deferred, per-position validation or exact preservation of constraint metadata through engine round trips.

TensorStore's bounds documentation explicitly permits omitting bounds after indices have been validated.

Validation:

  • 1,663 package tests and doctests passed.
  • 140 bounds cases cover both loaders, inclusive endpoints, finite and one-sided intervals, empty/singleton/multidimensional arrays, negative and zero strides, malformed/reversed bounds, integer extremes, serialization, and subsequent selection and translation.
  • Strict MkDocs build and applicable repository hooks passed.
  • Pyright: zero errors, 90 warnings.

Corresponding fork review: d-v-b#335.

Correct mathematical API documentation to match supported coordinate, grid, and chunk projection contracts.

Assisted-by: Codex:GPT-6
Retain the existing unsigned selector fix and update the unsupported mixed-dependency error assertion for general intersection routing.

Assisted-by: Codex:GPT-6
Use lexicographic tuple grouping when chunk indices contain negative values. Cover shared one-axis and two-axis array dependencies, repeated points, and extreme signed coordinates.

Assisted-by: Codex:GPT-6
@github-actions github-actions Bot added the needs release notes Automatically applied to PRs which haven't added release notes label Sep 13, 2026
@read-the-docs-community

read-the-docs-community Bot commented Sep 13, 2026

Copy link
Copy Markdown

Remove implementation history and unsupported historical claims from source and test docstrings. Distinguish immutable coordinate mappings from mutable source values.

Assisted-by: Codex:GPT-6
Preserve bounds-rejection behavior and documentation while incorporating the merged audit and planner improvements.

Assisted-by: Codex:GPT-6
Accept valid finite and one-sided bounds with eager validation shared by both JSON loaders. Validate before affine adjustment and simplification; immutable validated maps need no retained constraint.

Assisted-by: Codex:GPT-6
@d-v-b d-v-b changed the title fix(indexing): reject unsupported wire index array bounds fix(indexing): validate index-array bounds during JSON loading Sep 14, 2026
@d-v-b
d-v-b marked this pull request as ready for review September 14, 2026 11:07
@d-v-b
d-v-b merged commit 34dd17c into zarr-developers:main Sep 14, 2026
39 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant