fix(qdrant): raise ValueError for unsupported filter operators

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
kartik-mem0
2026-03-21 18:02:54 +05:30
parent 7e0968bbc8
commit fb430b1a32
2 changed files with 11 additions and 2 deletions
+5 -2
View File
@@ -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:
"""
+6
View File
@@ -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