Skip to content

fix(zarr-indexing): reject overflowing integer selectors - #4333

Draft
d-v-b wants to merge 4 commits into
zarr-developers:mainfrom
d-v-b:codex/zarr-indexing-checked-selectors
Draft

fix(zarr-indexing): reject overflowing integer selectors#4333
d-v-b wants to merge 4 commits into
zarr-developers:mainfrom
d-v-b:codex/zarr-indexing-checked-selectors

Conversation

@d-v-b

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

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Summary

Direct IndexTransform.oindex and .vindex selections cast integer arrays to np.intp before checking whether their values fit. On a domain containing negative coordinates, np.array([2**64 - 1], dtype="uint64") therefore silently selects coordinate -1.

Use the existing checked_affine(0, 1, ...) conversion for direct integer-array and list selectors. Coordinates outside the representable range now raise OverflowError before narrowing; valid coordinates keep their meaning. The positional LazyArray boundary already checks unsigned bounds and is unaffected.

For reviewers

Regression tests cover both direct indexing modes, the signed-range boundary and uint64 maximum, NumPy-array and list inputs, and read-only valid selectors with repeated/unsorted coordinates. Four NumPy-array cases silently succeeded before this fix; list inputs already raised an overflow error and now use the same diagnostic.

Validation: the zarr-indexing source test suite passes with 1,333 passed and 4 skipped (optional TensorStore/Dask unavailable), using the Python 3.12 minimal Hatch environment. Temporary distribution-version metadata was supplied for this source-only checkout, including its subprocess example; packaging was not tested by that run. Ruff lint and formatting pass.

Author attestation

  • I am a human, these are my changes, and I have reviewed and understood every change and can explain why each is correct.

TODO

  • Add regression tests
  • Add a subpackage changelog entry
  • Human author reviews the changes and edits the description
  • GitHub Actions have all passed

@github-actions github-actions Bot added the needs release notes Automatically applied to PRs which haven't added release notes label Sep 9, 2026
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