microsoft/semantic-kernel · error · NotImplementedError
Only 'and' of == comparisons is supported.
Error message
Only 'and' of == comparisons is supported.
What it means
When combining multiple comparisons the visitor (visit_BoolOp) only accepts ast.And. A BoolOp whose op is not `and` (e.g. `or`, or `not`-style logic) raises NotImplementedError before visiting children.
Source
Thrown at python/semantic_kernel/connectors/_search_shared.py:48
raise NotImplementedError("Left side must be x.FIELD.")
field = node.left.attr
if not (len(node.ops) == 1 and isinstance(node.ops[0], ast.Eq)):
raise NotImplementedError("Only == comparisons are supported.")
right = node.comparators[0]
if isinstance(right, ast.Constant):
if right.value is None:
raise NotImplementedError("None values are not supported.")
value = str(right.value)
else:
raise NotImplementedError("Only constant values are supported on the right side.")
if field not in self.valid_parameters:
raise ValueError(f"Field '{field}' is not supported.")
self.filters.append({field: quote_plus(value)})
@override
def visit_BoolOp(self, node):
if not isinstance(node.op, ast.And):
raise NotImplementedError("Only 'and' of == comparisons is supported.")
for v in node.values:
self.visit(v)
View on GitHub (pinned to c028a0c7dc)
Solutions
- Combine clauses only with `and` (`lambda x: x.a == 1 and x.b == 2`).
- OR-style multi-value matching is not supported by this filter DSL; narrow to a single value or run multiple queries and merge client-side.
Example fix
// before lambda x: x.country == "us" or x.country == "ca" // after lambda x: x.country == "us" # pick one; 'or' is unsupported by the visitor
Defensive patterns
Strategy: validation
Validate before calling
import ast
node = ast.parse(filter_src, mode='eval').body
def check_and(n):
if isinstance(n, ast.BoolOp):
assert isinstance(n.op, ast.And), "only 'and' supported"
for v in n.values: check_and(v)
check_and(node.body) Type guard
def boolop_is_and(node: ast.BoolOp) -> bool:
return isinstance(node.op, ast.And) Prevention
- Combine filter clauses only with 'and'
- Avoid 'or'/negation which the DSL does not support
- Run multiple queries and merge client-side for OR semantics
When it happens
Trigger: Using `or` between clauses: `lambda x: x.a == 1 or x.b == 2`, or any non-and boolean combination.
Common situations: Wanting OR semantics for multi-value filters; assuming full boolean expression support.
Related errors
- Left side must be x.FIELD.
- Only == comparisons are supported.
- None values are not supported.
- Only constant values are supported on the right side.
- Field '{field}' is not supported.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/ea9ca9d02a9664a6.
Report an issue: GitHub.