Skip to content

fix: limit LocalStore deletion to one object key - #4468

Open
guhou-hvi wants to merge 2 commits into
zarr-developers:mainfrom
guhou-hvi:fix/local-delete-single-key
Open

guhou-hvi wants to merge 2 commits into
zarr-developers:mainfrom
guhou-hvi:fix/local-delete-single-key

Conversation

@guhou-hvi

Copy link
Copy Markdown
Contributor

Summary

Addresses #2451.

MemoryStore preserves foo/bar when asked to delete the nonexistent key foo.
LocalStore can instead remove the objects beneath that prefix. A request to
delete one nonexistent key should not delete several other objects. The
maintainer distinguished single-key delete from recursive delete_dir in
#2451; #2606 documented the existing behavior without fixing it.

This change makes directory prefixes a no-op for LocalStore's delete and
delete_sync. Actual file deletion is unchanged. Callers relying on recursive
deletion must use delete_dir, or clear for the whole store.

For reviewers

The compatibility change is intentional. The old recursive-directory test is
replaced, the docstring and changelog explain migration, and an API test that
used root delete() for cleanup now uses delete_dir(). No public API or
dependency is added.

The 12 regression cases check complete key lists and bytes for directory/root
prefixes, plus file deletion, missing keys, explicit recursive deletion and
read-only protection. They give 8 failures and 4 passes on main, and all pass
with the fix. Selected store, group, array and API modules report 4642 passed
and 1134 skipped. Ruff, formatting, numpydoc and changelog checks pass. Mypy
reports the same 9 optional-obstore unused-ignore errors on main. File and
missing-key deletion medians increased by 2.4 and 0.7 microseconds in local
microbenchmarks. Actual symlink probes were skipped for Windows privileges.

Codex implemented the change and tests, ran the local checks, and helped
translate and organize this description; a separate Codex agent reviewed
the change. I have reviewed and understand the changes.

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.
  • Update the modified user-facing docstring.
  • Document changes and the migration in changes/.
  • GitHub Actions have all passed.
  • Test coverage is 100% (Codecov passes).

@codecov

codecov Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.68%. Comparing base (500673d) to head (da7869a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4468      +/-   ##
==========================================
- Coverage   94.69%   94.68%   -0.01%     
==========================================
  Files          94       94              
  Lines       13597    13596       -1     
==========================================
- Hits        12875    12874       -1     
  Misses        722      722              
Files with missing lines Coverage Δ
src/zarr/storage/_local.py 98.59% <100.00%> (-0.01%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
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.

1 participant