Skip to content

Regression: FsspecStore over ReferenceFileSystem fails with GroupNotFoundError (path '/' joined as '//key') #3922

@TomNicholas

Description

@TomNicholas

Describe the bug

zarr.open_group on an FsspecStore wrapping fsspec.implementations.reference.ReferenceFileSystem raises GroupNotFoundError on current main, even though the reference set contains a valid zarr.json.

This appears to be a regression from #3679 (be0a7b8), which in FsspecStore._get replaced

path = _dereference_path(self.path, key)

with

path = _join_paths([self.path, key])

These differ when self.path == "/" (which is what FsspecStore(fs=ReferenceFileSystem(...)) ends up with):

  • _dereference_path("/", "zarr.json")"zarr.json" (root is rstrip("/")ed to "", so no prefix is added)
  • _join_paths(["/", "zarr.json"])"//zarr.json" (only empty strings are filtered, so "/" is kept and joined with "/")

ReferenceFileSystem keys its refs by bare "zarr.json", so the lookup misses, _get raises FileNotFoundError, and open_group turns that into GroupNotFoundError.

Local-filesystem-backed FsspecStores aren't affected because their self.path is the full filesystem path (not "/"), so the extra slash never appears.

Steps to reproduce

Save as repro.py and run uv run repro.py:

# /// script
# requires-python = ">=3.11"
# dependencies = [
#     "fsspec",
#     "zarr",
# ]
# ///
import json

import fsspec
import zarr
from zarr.storage import FsspecStore
from zarr.storage._utils import _join_paths

group_json = json.dumps({"zarr_format": 3, "node_type": "group", "attributes": {}})
refs = {"version": 1, "refs": {"zarr.json": group_json}}

fs = fsspec.filesystem("reference", fo=refs, asynchronous=True)
store = FsspecStore(fs=fs, read_only=True)
print(f"zarr version: {zarr.__version__}")
print(f"store: {store!r}")
print(f"store.path: {store.path!r}")
print(f'_join_paths([store.path, "zarr.json"]) = {_join_paths([store.path, "zarr.json"])!r}')

zarr.open_group(store, mode="r")
print("SUCCESS — group opened")

Output on current main (3.1.7.dev45+g866aa8d67)

zarr version: 3.1.7.dev45+g866aa8d67
store: <FsspecStore(ReferenceFileSystem, /)>
store.path: '/'
_join_paths([store.path, "zarr.json"]) = '//zarr.json'
...
zarr.errors.GroupNotFoundError: No group found in store <FsspecStore(ReferenceFileSystem, /)> at path ''

Expected behavior

Same as on zarr 3.1.6: the group is opened successfully.

Environment

  • zarr: 3.1.7.dev45+g866aa8d67 (broken), 3.1.6 (works)
  • fsspec: 2026.3.0
  • Python: 3.13
  • OS: macOS / Linux (reproduced on both)

Bisect

Bisected v3.1.6..866aa8d6 to first bad commit be0a7b82 ("feat/memory store registry", #3679).

Downstream impact

Caught while reviewing zarr-developers/VirtualiZarr#957 — 18 kerchunk-roundtrip tests fail against upstream zarr for this reason.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions