Repository navigation
fix: preserve identifier types in PolarDB lightweight recall - #2551
Conversation
🤖 Open Code ReviewTarget: PR #2551 ✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). Generated by cloud-assistant via Open Code Review. |
|
## Description Merge `dev-v2.0.36` into `main` for MemOS v2.0.36. The final release-branch commit sets both the package version and `memos.__version__` to `2.0.36`. This release includes the PostgreSQL graph storage updates (#2531), knowledge memory and recall changes (#2479, #2436), and fixes for PolarDB recall (#2551), RabbitMQ shutdown (#2532), API key validation (#2491), and rate limiting (#2490). ## How Has This Been Tested? - [x] Unit tests — 24 passed in `tests/graph_dbs/test_postgres_400_compat.py` and `tests/mem_scheduler/test_rabbitmq_shutdown.py`. - [x] Verified that both version fields are `2.0.36`, ran `make format` and `git diff --check`, and simulated the merge with `main`. ## Checklist - [x] Reviewed the release diff and the two-file version commit. - [x] Verified the release branch merges cleanly with the current `main` locally.
Description
Fixes #2550.
PolarDB lightweight vector-search projections can return a numeric user ID as an already-decoded string. Decoding it again with
json.loadsturns it into an integer, causingTextualMemoryItemvalidation to fail and potentially leaving knowledge-base retrieval empty after successful ingestion.Preserve identifier strings (including leading zeros), normalize native integer identifiers to strings, and keep JSON-quoted strings and nulls compatible. Non-identifier arrays, objects, booleans and numeric values retain their existing decoding. The identifier field set is a module-level frozenset, avoiding per-field allocations during recall. No dependency, schema or route changes.
Type of change
How Has This Been Tested?
poetry run pytest tests/graph_dbs/ -q→ 77 passed, 3 skipped.make test→ 1005 passed, 9 skipped;make formatand changed-file pre-commit passed.b1a7d5fee60c06923933550c9c9c0755c54e383c(Linux, Windows, macOS 14/15; Python 3.10–3.13). Live cloud API testing is not applicable before deployment.Regression cases exercise a mocked database row through real lightweight vector search and real recall-item construction, covering digit strings, native integers, JSON-quoted strings, leading zeros and nulls. Before the fix, the numeric string/integer cases fail with Pydantic
metadata.user_idstring-type errors (2 failed, 26 passed); after the fix, all relevant tests pass. All fixtures are synthetic and external services are mocked.Checklist
Reviewer Checklist