Skip to content

fix: Feedback API fails with Neo4j CypherTypeError - Property values cannot be Map types #1122

@paneel

Description

@paneel

Pre-submission checklist | 提交前检查

  • I have searched existing issues and this hasn't been mentioned before | 我已搜索现有问题,确认此问题尚未被提及
  • I have read the project documentation and confirmed this issue doesn't already exist | 我已阅读项目文档并确认此问题尚未存在
  • This issue is specific to MemOS and not a general software issue | 该问题是针对 MemOS 的,而不是一般软件问题

Bug Description | 问题描述

The /product/feedback endpoint fails when using Neo4j as the graph backend. The API returns {"code":200,"data":[[]]} but no memory is created or updated.

Root Cause | 根本原因

Issue 1: Neo4j CypherTypeError

In src/memos/graph_dbs/neo4j_community.py:102, when add_node() is called with metadata containing nested objects, Neo4j rejects it:

neo4j.exceptions.CypherTypeError: Property values can only be primitive types or arrays thereof. Encountered: Map{user_name -> String("test-user-001")}.

Issue 2: IndexError in feedback.py

In src/memos/mem_feedback/feedback.py:254, when memory_manager.add() returns an empty list due to the Neo4j error, the code crashes:

return {
    "id": added_ids[0],  # IndexError: list index out of range

How to Reproduce | 如何重现

  1. Set up MemOS with Neo4j backend (neo4j-community)
  2. Add a memory:
curl -X POST http://localhost:8000/product/add \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "test-user-001",
    "mem_cube_id": "test-cube-001",
    "messages": [{"role": "user", "content": "I prefer Python for AI development"}],
    "async_mode": "sync"
  }'
  1. Try to provide feedback:
curl -X POST http://localhost:8000/product/feedback \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "test-user-001",
    "mem_cube_id": "test-cube-001",
    "memory_id": "<memory_id_from_step_2>",
    "history": [{"role": "user", "content": "I prefer Python for AI development"}],
    "feedback_content": "Actually I also like TypeScript"
  }'

Expected Behavior | 预期行为

  • Feedback should update or add memory
  • API should return the new/updated memory ID
  • No errors in logs

Actual Behavior | 实际行为

  • API returns: {"code":200,"message":"Memory feedback successfully","data":[[]]}
  • No memory created or updated
  • Logs show:
    • CypherTypeError: Property values can only be of primitive types
    • IndexError: list index out of range

Environment | 环境信息

  • MemOS: latest (built from main branch)
  • Neo4j: 5.x (neo4j:latest)
  • Python: 3.11
  • Deployment: Docker Compose

Additional Context | 补充信息

The function _flatten_info_fields() is used in add_nodes_batch() but not in add_node(). This may be related to the issue.

Willingness to Implement | 实现意愿

  • I'm willing to implement this myself | 我愿意自己解决
  • I would like someone else to implement this | 我希望其他人来解决

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpendingPending items to be addressed | 待解决事项。

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions