Skip to content

Zarr over https returns an empty string in keys() #3575

Closed

Description

@b8raoult

Zarr version

3.1.3

Numcodecs version

0.15.1

Python Version

3.12.9

Operating System

Mac

Installation

uv pip install zarr

Description

The following code:

import zarr, numcodecs

z = zarr.open('https://data.ecmwf.int/anemoi-datasets/era5-o96-1979-2023-6h-v8.zarr', mode='r')
print(list(z.keys()))

will show that one of the keys is the empty string ''. This is likely because the directory listing links to itself.

See https://data.ecmwf.int/anemoi-datasets/era5-o96-1979-2023-6h-v8.zarr

Steps to reproduce

# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",
# ]
# ///
#
# This script automatically imports the development branch of zarr to check for issues

import zarr
# your reproducer code
# zarr.print_debug_info()

Additional output

No response

Activity

  1. added
    bugPotential issues with the zarr-python library
    on Nov 9, 2025
  2. changed the title [-]Zarr over https returns and empty strings in `keys()`[/-] [+]Zarr over https returns an empty string in `keys()`[/+] on Nov 9, 2025
  3. d-v-b commented on Nov 9, 2025

    @d-v-b
    Contributor

    directory listing over http is not to my knowledge standardized, so we are relying on fsspec's heuristics, which iirc involve assuming that a request against "path/" follows the static file server contention of returning a list of links to path/a, path/b, etc. I'm not sure if this is something zarr or fsspec should fix. On our side, we could develop a special storage backend for http storage that deals with this.

  4. b8raoult commented on Nov 9, 2025

    @b8raoult
    Author

    I understand that. I just wanted to report it. I'll exclude the empty string in my code.

  5. d-v-b commented on Nov 9, 2025

    @d-v-b
    Contributor

    we should definitely not be conveying the existence of keys that do not exist, so as a short-term fix we should probably sanitize the results of directory listing

  6. b8raoult commented on Nov 9, 2025

    @b8raoult
    Author

    Please note that zarr 2.18.7 does not return that empty string.

  7. b8raoult commented on Nov 9, 2025

    @b8raoult
    Author

    But, zarr2 did return .zgroup. I expect keys() to return all arrays and sub-groups.

  8. d-v-b commented on Nov 9, 2025

    @d-v-b
    Contributor

    one step forward, one step back

  9. added a commit that references this issue on Sep 24, 2026
    34b7c3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions