Skip to content

keyv - fix: a namespaced clear() fails instead of wiping a store it can't scope - #2186

Merged
jaredwray merged 1 commit into
mainfrom
claude/dreamy-ramanujan-5sjbg9
Oct 3, 2026
Merged

jaredwray merged 1 commit into
mainfrom
claude/dreamy-ramanujan-5sjbg9

Conversation

@jaredwray

Copy link
Copy Markdown
Owner

Please check if the PR fulfills these requirements

  • Followed the Contributing and Code of Conduct guidelines.
  • Tests for the changes have been added (for bug fixes/features) with 100% code coverage.

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Bug fix that changes behavior, with docs. It's the second pre-GA fix, after jaredwray/keyv#2185.

KeyvMemoryAdapter.clear() and KeyvBridgeAdapter.clear() fell back to the store's own clear() when a namespace was set but they had no way to find its keys. That happened with a Map-like store without keys(), and with an async store without iterator() that doesn't manage its own namespace. The fallback deleted every namespace's entries, though the docs promise that clearing users doesn't touch cache.

Changes

  • Both adapters now throw a descriptive error in that case. Keyv.clear() already turns an adapter error into an error event, so nothing is deleted: the call resolves when a listener is attached and rejects when none is.
  • clear() without a namespace still empties the store, so a deliberate full wipe is still available. Stores that can be scoped behave as before: a Map, LRUs with keys(), stores with iterator(), adapters that manage their own namespace, and every v6 adapter.
  • Tests: the bridge test that asserted the wipe now expects the rejection, with both entries kept. New tests cover the memory adapter and the Keyv-level behavior on both paths: error emitted with a listener, a rejection without one, the store left alone, and a full clear without a namespace. They fail on main.
  • Docs: the README and the namespaces, Map/LRU, legacy adapter and methods pages. v5's Keyv.clear() called store.clear() directly and wiped everything, so the migration guide gets a section and table of contents entry, and the keyv-migrate skill references (v5-to-v6.md, custom-adapters.md) note the change, per AGENTS.md.

Verification

  • pnpm test in core/keyv: lint clean, 19 files and 367 tests pass, and every branch in bridge.ts and memory.ts is covered.
  • With the rebuilt keyv, these suites also pass: bigmap, test-suite, the three compression adapters, both encryption adapters, both serializers, sqlite, redis (against local Redis), and the website's docs and skill validation.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Wm1wtCGzQJEyYZdekgNVge


Generated by Claude Code

…an't scope

KeyvMemoryAdapter and KeyvBridgeAdapter fell back to the store's own
clear() when they had a namespace but no way to find its keys: a Map-like
store without keys(), or an async store without iterator() that doesn't
manage its own namespace. That deleted every namespace's entries, though
the docs promise that clearing `users` doesn't touch `cache`.

Both adapters now throw instead, and Keyv's clear() turns that into an
`error` event (a rejection with no listener), so nothing is deleted.
clear() without a namespace still empties the store, which keeps a
deliberate full wipe available. Stores that can be scoped (a Map, LRUs
with keys(), adapters with an iterator() or their own namespace) behave
as before.

v5 called the store's clear() directly and deleted everything, so the
migration guide and the keyv-migrate skill references get a section on
the change, and the README and the namespace, Map/LRU, legacy adapter
and method docs describe the new behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wm1wtCGzQJEyYZdekgNVge
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T23:03:45.289394Z 0cc7fc5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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 100.00%. Comparing base (b91b8bf) to head (0cc7fc5).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2186   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           56        56           
  Lines         5797      5798    +1     
  Branches       995       998    +3     
=========================================
+ Hits          5797      5798    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@jaredwray
jaredwray merged commit 790eb3c into main Oct 3, 2026
16 checks passed
@jaredwray
jaredwray deleted the claude/dreamy-ramanujan-5sjbg9 branch October 3, 2026 23:31
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