From fb430b1a3229da1c007160ddb80b86582a29a745 Mon Sep 17 00:00:00 2001 From: kartik-mem0 Date: Sat, 21 Mar 2026 18:02:54 +0530 Subject: [PATCH] fix(qdrant): raise ValueError for unsupported filter operators Co-Authored-By: Claude Sonnet 4.6 --- mem0/vector_stores/qdrant.py | 7 +++++-- tests/vector_stores/test_qdrant.py | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mem0/vector_stores/qdrant.py b/mem0/vector_stores/qdrant.py index 2833c75c6..d074a8923 100644 --- a/mem0/vector_stores/qdrant.py +++ b/mem0/vector_stores/qdrant.py @@ -180,8 +180,11 @@ class Qdrant(VectorStoreBase): text = value.get("contains") or value.get("icontains") return FieldCondition(key=key, match=MatchText(text=text)) else: - # Unknown operator — fall back to equality - return FieldCondition(key=key, match=MatchValue(value=value)) + supported = {"eq", "ne", "gt", "gte", "lt", "lte", "in", "nin", "contains", "icontains"} + raise ValueError( + f"Unsupported filter operator(s) for field '{key}': {ops}. " + f"Supported operators: {supported}" + ) def _create_filter(self, filters: dict) -> Filter: """ diff --git a/tests/vector_stores/test_qdrant.py b/tests/vector_stores/test_qdrant.py index d64bb46ed..845167d7e 100644 --- a/tests/vector_stores/test_qdrant.py +++ b/tests/vector_stores/test_qdrant.py @@ -535,5 +535,11 @@ class TestQdrantEnhancedFilters(unittest.TestCase): self.assertEqual(result.must[0].range.gte, 5) self.assertEqual(result.must[0].range.lte, 10) + def test_unknown_operator_raises_error(self): + """Unknown operator dict should raise ValueError, not ValidationError.""" + with self.assertRaises(ValueError) as ctx: + self.qdrant._build_field_condition("field", {"unknown_op": "foo"}) + self.assertIn("Unsupported", str(ctx.exception)) + def tearDown(self): del self.qdrant