Skip to content

Support gzip and zlib 'level' of -1 in v2 metadata - #106

Merged
normanrz merged 1 commit into
zarr-developers:mainfrom
stefanhahmann:support-gzip-level-minus-one
Sep 21, 2026
Merged

normanrz merged 1 commit into
zarr-developers:mainfrom
stefanhahmann:support-gzip-level-minus-one

Conversation

@stefanhahmann

@stefanhahmann stefanhahmann commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Description

numcodecs writes zlib's Z_DEFAULT_COMPRESSION (-1) as the level of gzip and zlib compressors, meaning "let the library choose". Both v2 codecs rejected it while parsing .zarray, so such an array could not be opened at all.

Deflater takes -1 as-is, so the value is passed through unchanged and only the lower bound of the check moves. Same shape as #102, which fixed the analogous -1 gap for blosc's shuffle. ZlibCodec carried the identical check, so it is fixed here too.

Related issues

Reported for gzip in mobie/mobie-io#181, on a dataset written by n5-zarr.

Checklist

  • Added tests for the new behavior or bug fix — ZarrV2Test.testReadDefaultCompressionLevel, parameterized over gzip and zlib, following the pattern of Support blosc 'shuffle' of -1 in v2 metadata #102's test
  • Updated USERGUIDE.md / USERGUIDE-OME-ZARR.md if the public API changed — n/a, the accepted level range only widens

🤖 Generated with Claude Code

Other implementations write zlib's Z_DEFAULT_COMPRESSION (-1) as the
'level' of gzip and zlib, meaning "let the library choose". Both codecs
rejected it while parsing .zarray, so such an array could not be opened.
Deflater takes -1 as-is, so only the lower bound of the check moves.

Reported for gzip in mobie/mobie-io#181.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tischi

tischi commented Sep 21, 2026

Copy link
Copy Markdown

Hi @normanrz, would be great if that could be merged and released soon, as it currently is a blocker for a mobie-io zarr3 release; unless I comment out a few valid tests :-)

@normanrz
normanrz merged commit 6ba486b into zarr-developers:main Sep 21, 2026
3 checks passed
@normanrz

Copy link
Copy Markdown
Member

0.3.1 is out

@stefanhahmann
stefanhahmann deleted the support-gzip-level-minus-one branch September 22, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants