Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

fix(pinecone): return [[]] from list() error path instead of dict (#5706)

Hrushikesh Yadavbd5996f41ec4
diff --git a/mem0/vector_stores/pinecone.py b/mem0/vector_stores/pinecone.py
index 91be9efdb..733db6ca8 100644
--- a/mem0/vector_stores/pinecone.py
+++ b/mem0/vector_stores/pinecone.py
@@ -391,7 +391,7 @@ class PineconeDB(VectorStoreBase):
return [results]
except Exception as e:
logger.error(f"Error listing vectors: {e}")
- return {"points": [], "next_page_token": None}
+ return [[]]
def count(self) -> int:
"""
diff --git a/tests/vector_stores/test_pinecone.py b/tests/vector_stores/test_pinecone.py
index 89194aea1..06980fe82 100644
--- a/tests/vector_stores/test_pinecone.py
+++ b/tests/vector_stores/test_pinecone.py
@@ -188,3 +188,11 @@ def test_count_with_none_vector_count(pinecone_db):
count = pinecone_db.count()
assert count == 0
pinecone_db.index.describe_index_stats.assert_called_once()
+
+
+def test_list_error_returns_list_not_dict(pinecone_db):
+ """list() error path must return [[]] so callers can do result[0]."""
+ pinecone_db.index.query.side_effect = Exception("connection error")
+ result = pinecone_db.list(filters={"user_id": "alice"}, top_k=10)
+ assert isinstance(result, list)
+ assert result == [[]]