fix(feedback): handle empty added_ids in _single_add_operation#1143
Closed
lailoo wants to merge 1 commit intoMemTensor:mainfrom
Closed
fix(feedback): handle empty added_ids in _single_add_operation#1143lailoo wants to merge 1 commit intoMemTensor:mainfrom
lailoo wants to merge 1 commit intoMemTensor:mainfrom
Conversation
…nsor#1122) When memory_manager.add() returns an empty list due to a silent graph DB failure, accessing added_ids[0] raises IndexError. Add a guard to return {"id": None, ...} gracefully instead of crashing.
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.
Summary
IndexErrorin_single_add_operationwhenmemory_manager.add()returns empty listfeedback.py:254accessesadded_ids[0]without checking if the list is empty{"id": None, ...}gracefullyFixes #1122 (Part 2 of 2 — the IndexError on empty added_ids)
Problem
When the graph DB silently fails (e.g. due to the CypherTypeError in Part 1),
_add_memories_parallel()catches the exception, logs it, but returns an empty list. Then_single_add_operationcrashes:Before fix:
Changes
src/memos/mem_feedback/feedback.py— Add empty-list guard before accessingadded_ids[0]tests/mem_feedback/test_feedback_empty_added_ids.py— Regression testsAfter fix:
Test plan
test_single_add_returns_none_id_when_added_ids_empty— verifies graceful handlingtest_single_add_returns_id_when_added_ids_present— verifies normal pathEffect on User Experience
Before:
/product/feedbackendpoint crashes with 500 Internal Server Error when the underlying graph DB add fails silently.After: The endpoint returns a response with
"id": null, allowing the caller to detect and handle the failure.