Repository navigation
Conversation
…emTensor#2288) `_sanitize_neo4j_value` serializes every dict-typed metadata value into a JSON string on write, but `_parse_node` / `_parse_nodes` only reversed the `sources` transform. `internal_info` and `info` therefore came back as `str`, breaking `TextualMemoryItem`'s `dict | None` validation during recall on document-ingest / Dream-enabled deployments. Adds a small `_deserialize_dict_field` helper (symmetric with the write-side sanitizer) and wires it into both `Neo4jGraphDB._parse_node` and `Neo4jCommunityGraphDB._parse_node` / `_parse_nodes` for the two known dict-typed fields. JSON-object-shaped strings deserialize to dicts, malformed strings fall back to None so pydantic still accepts them, all other values pass through unchanged. Write path and other graph backends untouched. Adds 16 regression tests including an end-to-end guard that feeds the parser output into `TreeNodeTextualMemoryMetadata` to close the loop with the failure point. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Address two OCR findings on MemTensor#2289: 1. src/memos/graph_dbs/neo4j.py: `_deserialize_dict_field` silently dropped malformed dict-shaped strings to None, making the event indistinguishable from a legitimately-None field. Emit a `logger.warning` before returning None so operators can trace the corruption. Uses the module-level logger already declared at line 13. 2. tests/graph_dbs/test_neo4j_internal_info_roundtrip.py: `TestDeserializeDictField._helper` is a stable module-level lookup with no `self` use — promote it to `@staticmethod` for idiomatic pytest style. Verified: pytest tests/graph_dbs/ (47 passed, 3 pre-existing skips) + ruff check/format clean on both files.
endxxxx
approved these changes
Nov 19, 2026
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.
Description
Historical Neo4j records can contain info as a JSON object string. Building a TextualMemoryItem from those records fails dict validation, even though the same representation is already supported for internal_info by #2517.
Extend the existing metadata validator to info and report the relevant field name for encoded non-object values. Existing dictionaries, None, missing info and modern flattened metadata remain compatible. Malformed JSON, encoded arrays/scalars and double-encoded strings raise ValidationError.
This PR is based on dev-v2.0.37 and retains the original #2289 contribution history. The final diff concentrates the remaining fix at the metadata validation boundary. Its tests exercise the native Neo4j single-node and Community single/batch parsers through TextualMemoryItem construction, including embedding alignment and strict handling of corrupt records.
Fixes #2288.
Type of change
How Has This Been Tested?
Actual verification output
The nine skips are opt-in database integration tests with services unconfigured. The Neo4j parser regressions use mocked vector clients. This run exercises the parser/model boundary with synthetic legacy records.
Before the validator change, the focused regression suite produced 12 failures and 82 passing controls. Repository pre-commit hooks passed on the follow-up commit.
Checklist
Reviewer Checklist