fix: correct LMDB has() logic inversion#21780
Merged
Merged
Conversation
alexghr
approved these changes
Mar 19, 2026
Contributor
|
Good find. This shows there was not test for this code path but also it's dead code as it's not used anywhere. |
PhilWindle
approved these changes
Mar 24, 2026
alexghr
approved these changes
Mar 24, 2026
## Summary Fixes a logic error in `LMDBStoreWrapper::has()` where `std::find` result was compared against `values->begin()` instead of `values->end()`, causing inverted existence checks. **Bug**: `std::find` returns `end()` when not found, but the code compared against `begin()`: - Value found at position 0: `begin() != begin()` → **false** (wrong) - Value not found: `end() != begin()` → **true** (wrong) **Fix**: Changed `!= values->begin()` to `!= values->end()`. **Refactor**: Moved the `has()` logic from the NAPI wrapper (`LMDBStoreWrapper`) down to `LMDBStore` so it can be tested without Node.js. The wrapper now delegates to `_store->has()`. **Tests**: Added 7 new tests covering: - Missing key → false - Existing key (key-only check) → true - Value present → true - Value missing → false - All-of semantics (all requested values must be present) - Mixed entries in a single call - Duplicate key deduplication All 47 lmdblib tests pass (40 existing + 7 new). Resolves https://linear.app/aztec-labs/issue/A-846/claude-lmdb-logic-error
25f768a to
227895e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a logic error in
LMDBStoreWrapper::has()wherestd::findresult was compared againstvalues->begin()instead ofvalues->end(), causing inverted existence checks.Bug:
std::findreturnsend()when not found, but the code compared againstbegin():begin() != begin()→ false (wrong)end() != begin()→ true (wrong)Fix: Changed
!= values->begin()to!= values->end().Refactor: Moved the
has()logic from the NAPI wrapper (LMDBStoreWrapper) down toLMDBStoreso it can be tested without Node.js. The wrapper now delegates to_store->has().Tests: Added 7 new tests covering:
All 47 lmdblib tests pass (40 existing + 7 new).
Fix A-846 A-847