Repository navigation
fix: use .get() for user_review to prevent KeyError - #4500
Merged
Merged
Conversation
Memory documents may be missing the user_review field, causing KeyError when filtering memories in get_memories(). Using .get() returns None for missing keys, which correctly passes the `is not False` check. Fixes #4498 Co-Authored-By: Claude Opus 4.5 <[email protected]>
Collaborator
Author
|
@beastoin The fix looks right, but please add a regression test for by AI for @beastoin |
Tests verify the user_review filtering logic in get_memories(): - Missing field -> included (None is not False) - user_review=None -> included - user_review=True -> included - user_review=False -> excluded - Verifies old behavior would KeyError Co-Authored-By: Claude Opus 4.5 <[email protected]>
Collaborator
Author
|
Added regression tests in
All tests pass locally ( |
Collaborator
Author
Collaborator
Author
|
lgtm @beastoin |
Glucksberg
pushed a commit
to Glucksberg/omi-local
that referenced
this pull request
Apr 28, 2026
Fixes BasedHardware#4498 Changed `memory['user_review']` to `memory.get('user_review')` in `backend/database/memories.py:94` to prevent KeyError when memory documents are missing the `user_review` field. The `.get()` method returns `None` for missing keys, which correctly passes the `is not False` check, preserving the original behavior of including all memories except those explicitly marked `False`. Added regression tests covering missing field, None, True, False, and mixed values. **deploy:** - [ ] deploy backend --- _by AI for @beastoin_
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.
Fixes #4498
Changed
memory['user_review']tomemory.get('user_review')inbackend/database/memories.py:94to prevent KeyError when memory documents are missing theuser_reviewfield. The.get()method returnsNonefor missing keys, which correctly passes theis not Falsecheck, preserving the original behavior of including all memories except those explicitly markedFalse. Added regression tests covering missing field, None, True, False, and mixed values.deploy:
by AI for @beastoin