{"record":{"id":"b0cace6172b0ec60","repo":"microsoft/semantic-kernel","slug":"boolean-operator-type-node-op-name-is-not","errorCode":null,"errorMessage":"Boolean operator '{type(node.op).__name__}' is not allowed in filter expressions.","messagePattern":"Boolean operator '(.+?)' is not allowed in filter expressions\\.","errorType":"exception","errorClass":"VectorStoreOperationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/in_memory.py","lineNumber":229,"sourceCode":"        return result\n\n    def _eval_BoolOp(self, node: ast.BoolOp, context: Mapping[str, Any]) -> Any:\n        \"\"\"Evaluate boolean operators with Python short-circuit semantics.\"\"\"\n        if isinstance(node.op, ast.And):\n            result = self.evaluate(node.values[0], context)\n            for value in node.values[1:]:\n                if not result:\n                    return result\n                result = self.evaluate(value, context)\n            return result\n        if isinstance(node.op, ast.Or):\n            result = self.evaluate(node.values[0], context)\n            for value in node.values[1:]:\n                if result:\n                    return result\n                result = self.evaluate(value, context)\n            return result\n        raise VectorStoreOperationException(\n            f\"Boolean operator '{type(node.op).__name__}' is not allowed in filter expressions.\"\n        )\n\n    def _eval_UnaryOp(self, node: ast.UnaryOp, context: Mapping[str, Any]) -> Any:\n        \"\"\"Evaluate a unary operator.\"\"\"\n        operand = self.evaluate(node.operand, context)\n        if isinstance(node.op, ast.Not):\n            return not operand\n        raise VectorStoreOperationException(\n            f\"Unary operator '{type(node.op).__name__}' is not allowed in filter expressions.\"\n        )\n\n    def _eval_Compare(self, node: ast.Compare, context: Mapping[str, Any]) -> bool:\n        \"\"\"Evaluate a comparison expression.\"\"\"\n        left = self.evaluate(node.left, context)\n        for operator_node, comparator in zip(node.ops, node.comparators, strict=True):\n            right = self.evaluate(comparator, context)\n            if not self._compare(operator_node, left, right):","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/in_memory.py#L211-L247","documentation":"_eval_BoolOp handles only ast.And and ast.Or; any other operator type raises VectorStoreOperationException. In standard Python AST a BoolOp is always And or Or, so this branch is effectively unreachable through normal lambda parsing and serves purely as a defense-in-depth guard against crafted/modified AST.","triggerScenarios":"Not reachable via ordinary Python source; would require hand-constructed or post-processed AST with a non-standard BoolOp operator.","commonSituations":"Effectively none in normal use; relevant only to AST manipulation or a corrupted/custom parse pipeline.","solutions":["Use the standard boolean operators 'and' / 'or' in filter expressions.","Do not construct or mutate filter AST by hand; pass lambdas or string lambdas only."],"exampleFix":"# no normal Python source triggers this; use standard operators\nVectorSearchOptions(filter=lambda x: x.a == 1 and x.b == 2)","handlingStrategy":"validation","validationCode":"import ast\n\ndef uses_only_bool_ops(filter_str: str) -> None:\n    for node in ast.walk(ast.parse(filter_str, mode='eval')):\n        if isinstance(node, ast.BoolOp) and not isinstance(node.op, (ast.And, ast.Or)):\n            raise ValueError(f\"boolean operator {type(node.op).__name__} is not allowed\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only 'and' / 'or' in filter expressions.","Do not hand-construct filter AST."],"tags":["in-memory","filter","ast"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}