Skip to content

fix: preserve memory alongside source text in search results - #2175

Closed
bittergreen wants to merge 1 commit into
MemTensor:dev-v2.0.27from
bittergreen:wq-dev-v2.0.27
Closed

bittergreen wants to merge 1 commit into
MemTensor:dev-v2.0.27from
bittergreen:wq-dev-v2.0.27

Conversation

@bittergreen

Copy link
Copy Markdown
Contributor

Description

fix: preserve memory alongside source text in search results

Type of change

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

How Has This Been Tested?

  • Unit Test: tests/api/test_search_pipeline_hooks.py

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 | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

Reviewer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed
  • Tests have been provided

@Memtensor-AI Memtensor-AI added area:api 云服务 / FastAPI / OpenAPI / MCP status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Jul 28, 2026
@Memtensor-AI

Copy link
Copy Markdown
Collaborator

🤖 Open Code Review

Target: PR #2175
Task: 7ced30b1d3ac2dfa
Base: dev-v2.0.27
Head: wq-dev-v2.0.27

🔍 OpenCodeReview found 1 issue(s) in this PR.


1. src/memos/api/handlers/formatters_handler.py (L204)

Direct index access sources[0] will raise IndexError if the sources list is empty. Since the list is cleared (= []) later in the same loop, any upstream data anomaly with an empty sources could crash here. Guard with a length check or use .get-style access.

Suggested fix:

sources = item["metadata"].get("sources", [])
source_content = sources[0]["content"] if sources else ""

Generated by cloud-assistant via Open Code Review.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

✅ Automated Test Results: PASSED

All tests passed (6/6 executed). memos_python_core/changed-repo-python: 6/6. Duration: 8s

Branch: wq-dev-v2.0.27

@Memtensor-AI Memtensor-AI added status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发 and removed status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:api 云服务 / FastAPI / OpenAPI / MCP status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants