Conversation
Already-serialized memory entries crashed with KeyError when the id key was missing and AttributeError when the id was not a string. Derive the ref_id from the string form when an id exists and skip it otherwise. Fixes MemTensor#2448
Collaborator
🤖 Open Code ReviewTarget: PR #2449 ✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s). Generated by cloud-assistant via Open Code Review. |
Collaborator
✅ Automated Test Results: PASSEDAll tests passed (4/4 executed). memos_python_core/changed-repo-python: 4/4. Duration: 8s [advisory, non-gating] AI-generated tests on branch test/auto-gen-350cec654abe26f4-20261001000641: 44/44 passed — these do NOT affect the PR verdict; review the branch manually. Branch: |
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 #2448
Summary
prepare_reference_datainsrc/memos/mem_os/utils/reference_utils.pyhandlesTextualMemoryItemobjects and raw dicts, but the dict branch assumes every key exists and thatidis a string:Both escape the streaming pipeline for memory entries that are not
TextualMemoryIteminstances (e.g. already-serialized dicts from a cache or an MCP payload).Fix
Read the id defensively: derive
ref_idfrom the string form when an id exists, skip it otherwise.TextualMemoryItembehavior is unchanged.Regression test
Added
tests/mem_os/test_prepare_reference_data.py:TextualMemoryItemand string-id dict paths as unchangedruff check(repo-pinned 0.11.8) passes on both touched files.AI Disclosure