Skip to content

fix: list nested prefixes when FsspecStore path is "" or "/" - #4452

Merged
d-v-b merged 2 commits into
zarr-developers:mainfrom
bendichter:fix/fsspec-list-dir-bare-root
Sep 29, 2026
Merged

d-v-b merged 2 commits into
zarr-developers:mainfrom
bendichter:fix/fsspec-list-dir-bare-root

Conversation

@bendichter

@bendichter bendichter commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

list_dir and list_prefix joined the store path and the prefix with a "/", so a store rooted at "" or "/" asked the filesystem for "/a" or "//a". ReferenceFileSystem keys entries by bare names and does not find those, so nested groups listed as empty. FsspecStore.from_url with "reference://" gives a path of "", so this affected kerchunk-style references opened the usual way. Reads were already handled by _dereference_path.

import json

import zarr

group = json.dumps({"zarr_format": 3, "node_type": "group"})
refs = {"version": 1, "refs": {"zarr.json": group, "a/zarr.json": group, "a/b/zarr.json": group}}

root = zarr.open_group("reference://", storage_options={"fo": refs}, mode="r")

print(list(root.group_keys()))       # ['a']
print(list(root["a"].group_keys()))  # expected ['b']
print(root["a/b"].path)              # 'a/b', so the group exists

With zarr 3.4.0 and fsspec 2026.9.0, the output is:

['a']
[]
a/b

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 unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.md
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

list_dir and list_prefix joined the store path and the prefix with a
"/", so a store rooted at "" or "/" asked the filesystem for "/a" or
"//a". ReferenceFileSystem keys entries by bare names and does not find
those, so nested groups listed as empty. FsspecStore.from_url with
"reference://" gives a path of "", so this affected kerchunk-style
references opened the usual way. Reads were already handled by
_dereference_path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the needs release notes Automatically applied to PRs which haven't added release notes label Sep 29, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the needs release notes Automatically applied to PRs which haven't added release notes label Sep 29, 2026
@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.44%. Comparing base (319bfa4) to head (1ed2d45).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4452      +/-   ##
==========================================
+ Coverage   94.43%   94.44%   +0.01%     
==========================================
  Files          93       93              
  Lines       13219    13221       +2     
==========================================
+ Hits        12483    12487       +4     
+ Misses        736      734       -2     
Files with missing lines Coverage Δ
src/zarr/storage/_fsspec.py 91.80% <100.00%> (+0.09%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@d-v-b

d-v-b commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

thanks for this, and sorry for the bugged behavior. I'm having a look now

@d-v-b
d-v-b merged commit 5e3d8a4 into zarr-developers:main Sep 29, 2026
39 checks passed
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.

2 participants