fix(vector_stores): return None from get() for missing IDs (milvus/weaviate/supabase) (#5562)

Co-authored-by: ly-wang19 <ly-wang19@users.noreply.github.com>
This commit is contained in:
ly-wang19
2026-06-16 11:52:59 +05:30
committed by GitHub
co-authored by ly-wang19
parent b55c51e004
commit bb69b036b5
6 changed files with 29 additions and 15 deletions
+6 -6
View File
@@ -4,9 +4,7 @@ import uuid
from unittest.mock import MagicMock, patch
import dotenv
import httpx
import weaviate
from weaviate.exceptions import UnexpectedStatusCodeException
from mem0.vector_stores.weaviate import Weaviate
@@ -112,11 +110,13 @@ class TestWeaviateDB(unittest.TestCase):
assert result.payload == expected_payload
def test_get_not_found(self):
mock_response = httpx.Response(status_code=404, json={"error": "Not found"})
# fetch_object_by_id returns None for an unknown id; get() must return
# None rather than raising AttributeError on response.properties.
self.client_mock.collections.get.return_value.query.fetch_object_by_id.return_value = None
self.client_mock.collections.get.return_value.data.get_by_id.side_effect = UnexpectedStatusCodeException(
"Not found", mock_response
)
result = self.weaviate_db.get(vector_id=str(uuid.uuid4()))
assert result is None
def test_search(self):
mock_objects = [{"uuid": "id1", "properties": {"key1": "value1"}, "metadata": {"distance": 0.2}}]