Skip to content

fix: preserve identifier types in PolarDB lightweight recall - #2551

Merged
syzsunshine219 merged 2 commits into
dev-v2.0.36from
codex/fix-polardb-lightweight-identifiers
Oct 29, 2026
Merged

syzsunshine219 merged 2 commits into
dev-v2.0.36from
codex/fix-polardb-lightweight-identifiers

Conversation

@endxxxx

@endxxxx endxxxx commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes #2550.

PolarDB lightweight vector-search projections can return a numeric user ID as an already-decoded string. Decoding it again with json.loads turns it into an integer, causing TextualMemoryItem validation 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

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit Test: poetry run pytest tests/graph_dbs/ -q → 77 passed, 3 skipped.
  • Test Script Or Test Steps: make test → 1005 passed, 9 skipped; make format and changed-file pre-commit passed.
  • Pipeline verification: all 16 Python tests CI jobs passed on final head 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_id string-type errors (2 failed, 26 passed); after the fix, all relevant tests pass. All fixtures are synthetic and external services are mocked.

Checklist

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • Documentation issue/PR: not applicable; no public API changes.
  • I have linked the issue to this PR: fix: preserve numeric identifiers in PolarDB lightweight recall #2550.
  • Reviewer mentioned: @endxxxx.

Reviewer Checklist

@Memtensor-AI Memtensor-AI added area:database graph_db + vector_db | 图数据库与向量数据库 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Oct 29, 2026
@Memtensor-AI
Memtensor-AI requested a review from wustzdy October 29, 2026 10:34
@Memtensor-AI

Memtensor-AI commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 Open Code Review

Target: PR #2551
Task: 76289f0ed9dd0b83
Base: dev-v2.0.36
Head: codex/fix-polardb-lightweight-identifiers

✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

Generated by cloud-assistant via Open Code Review.

@syzsunshine219
syzsunshine219 merged commit 0e58d0e into dev-v2.0.36 Oct 29, 2026
17 of 18 checks passed
@syzsunshine219
syzsunshine219 deleted the codex/fix-polardb-lightweight-identifiers branch October 29, 2026 11:26
@Memtensor-AI

Copy link
Copy Markdown
Collaborator

⚠️ Automated Test Results: ENV ISSUE

The test environment encountered an issue that requires manual attention.

Details: Required Python dependency is unavailable. Automated validation remains blocked.
[tests/graph_dbs/test_search_return_fields.py] test_return_fields_included_in_results: ../../repo/tests/graph_dbs/test_search_return_fields.py:33: in neo4j_db
with patch("neo4j.GraphDatabase") as mock_gd:
/usr/lib/python3.10/unittest/mock.py:1431: in enter
self.target = self.getter()
/usr/lib/python3.10/unittest/mock.py:1618: in
getter = lambda: _importer(target)
/usr/lib/python3.10/unittest/mock.py:1257: in _importer
thing = import(import_path)
E ModuleNotFoundError: No module named 'neo4j'

[tests/graph_dbs/test_search_return_fields.py] test_backward_compatible_without_return_fields: ../../repo/tests/graph_dbs/test_search_return_fields.py:33: in neo4j_db
with patch("neo4j.GraphDatabase") as mock_gd:
/usr/lib/python3.10/unittest/mock.py:1431: in enter
self.target = self.getter()
/usr/lib/python3.10/unittest/mock.py:1618: in
getter = lambda: _importer(target)
/usr/lib/python3.10/unittest/mock.py:1257: in _importer
thing = import(import_path)
E ModuleNotFoundError: No module named 'neo4j'

[tests/graph_dbs/test_search_return_fields.py] test_cypher_return_clause_includes_fields: ../../repo/tests/graph_dbs/test_search_return_fields.py:33: in neo4j_db
with patch("neo4j.GraphDatabase") as mock_gd:
/usr/lib/python3.10/unittest/mock.py:1431: in enter
self.target = self.getter()
/usr/lib/python3.10/unittest/mock.py:1618: in
getter = lambda: _importer(target)
/usr/lib/python3.10/unittest/mock.py:1257: in _importer
thing = import(import_path)
E ModuleNotFoundError: No module named 'neo4j'

[tests/graph_dbs/test_search_return_fields.py] test_cypher_return_clause_default: ../../repo/tests/graph_dbs/test_search_return_fields.py:33: in neo4j_db
with patch("neo4j.GraphDatabase") as mock_gd:
/usr/lib/python3.10/unittest/mock.py:1431: in enter
self.target = self.getter()
/usr/lib/python3.10/unittest/mock.py:1618: in
getter = lambda: _importer(target)
/usr/lib/python3.10/unittest/mock.py:1257: in _importer
thing = import(import_path)
E ModuleNotFoundError: No module named 'neo4j'

[tests/graph_dbs/test_search_return_fields.py] test_return_fields_skips_id_field: ../../repo/tests/graph_dbs/test_search_return_fields.py:33: in neo4j_db
with patch("neo4j.GraphDatabase") as mock_gd:
/usr/lib/python3.10/unittest/mock.py:1431: in enter
self.target = self.getter()
/usr/lib/python3.10/unittest/mock.py:1618: in
getter = lambda: _importer(target)
/usr/lib/python3.10/unittest/mock.py:1257: in _importer
thing = import(import_path)
E ModuleNotFoundError: No module named 'neo4j' [advisory, non-gating] AI-generated tests on branch test/auto-gen-76289f0ed9dd0b83-20261029192601: 151/153 passed, 2 failed — these do NOT affect the PR verdict; review the branch manually.
Branch: codex/fix-polardb-lightweight-identifiers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:database graph_db + vector_db | 图数据库与向量数据库 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants