{"record":{"id":"9bbe18da7e48b1e9","repo":"microsoft/semantic-kernel","slug":"unsupported-operator-type-op-9bbe18","errorCode":null,"errorMessage":"Unsupported operator: {type(op)}","messagePattern":"Unsupported operator: (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/azure_cosmos_db.py","lineNumber":931,"sourceCode":"                    match op:\n                        case ast.In():\n                            # Cosmos DB: ARRAY_CONTAINS(right, left)\n                            return f\"ARRAY_CONTAINS({right}, {left})\"\n                        case ast.NotIn():\n                            return f\"NOT ARRAY_CONTAINS({right}, {left})\"\n                        case ast.Eq():\n                            return f\"{left} = {right}\"\n                        case ast.NotEq():\n                            return f\"{left} != {right}\"\n                        case ast.Gt():\n                            return f\"{left} > {right}\"\n                        case ast.GtE():\n                            return f\"{left} >= {right}\"\n                        case ast.Lt():\n                            return f\"{left} < {right}\"\n                        case ast.LtE():\n                            return f\"{left} <= {right}\"\n                    raise NotImplementedError(f\"Unsupported operator: {type(op)}\")\n                case ast.BoolOp():\n                    op_str = \"AND\" if isinstance(node.op, ast.And) else \"OR\"\n                    return \"(\" + f\" {op_str} \".join([parse(v) for v in node.values]) + \")\"\n                case ast.UnaryOp():\n                    match node.op:\n                        case ast.Not():\n                            return f\"NOT ({parse(node.operand)})\"\n                        case ast.UAdd():\n                            return f\"+{parse(node.operand)}\"\n                        case ast.USub():\n                            return f\"-{parse(node.operand)}\"\n                        case ast.Invert():\n                            raise NotImplementedError(\"Invert operation is not supported.\")\n                    raise NotImplementedError(f\"Unsupported unary operator: {type(node.op)}\")\n                case ast.Attribute():\n                    # Cosmos DB: c.field_name\n                    if node.attr not in self.definition.storage_names:\n                        raise VectorStoreOperationException(","sourceCodeStart":913,"sourceCodeEnd":949,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/azure_cosmos_db.py#L913-L949","documentation":"The connector translates Python filter lambdas into Cosmos SQL by walking the AST. Inside a comparison node it only maps a fixed set of operators (In, NotIn, Eq, NotEq, Gt, GtE, Lt, LtE). Any comparison operator not in that set reaches the trailing raise NotImplementedError. This means the filter expression used a Python comparison that the translator was never taught to render as SQL.","triggerScenarios":"Writing a filter lambda using an unsupported comparison operator, most commonly identity checks (a is b / a is not b, i.e. ast.Is / ast.IsNot) which Python emits for the 'is' keyword. The AST visitor's Compare branch has no case for them.","commonSituations":"A developer writes lambda x: x.category is None or x.tag is sentinel in a VectorSearchOptions.filter, expecting equality semantics; 'is' compiles to ast.Is, which is unsupported, whereas == compiles to ast.Eq and would work.","solutions":["Replace 'is'/'is not' comparisons with '=='/'!=' in the filter lambda so they compile to ast.Eq / ast.NotEq, which the translator supports.","Restrict filters to the supported operator set (==, !=, <, >, <=, >=, in, not in) and the supported logical/unary ops.","For null checks use == None / != None rather than is None / is not None."],"exampleFix":"// before\noptions = VectorSearchOptions(filter=lambda x: x.category is None)\n// after\noptions = VectorSearchOptions(filter=lambda x: x.category == None)\n","handlingStrategy":"validation","validationCode":"import ast\nSUPPORTED_OPS = (ast.Eq, ast.NotEq, ast.Gt, ast.GtE, ast.Lt, ast.LtE, ast.In, ast.NotIn)\ntree = ast.parse(filter_src, mode=\"eval\")\nfor node in ast.walk(tree):\n    if isinstance(node, ast.Compare):\n        for op in node.ops:\n            if not isinstance(op, SUPPORTED_OPS):\n                raise ValueError(f\"Filter uses unsupported operator: {type(op).__name__}\")","typeGuard":"def is_supported_filter_op(node: ast.Compare) -> bool:\n    ok = (ast.Eq, ast.NotEq, ast.Gt, ast.GtE, ast.Lt, ast.LtE, ast.In, ast.NotIn)\n    return all(isinstance(op, ok) for op in node.ops)","tryCatchPattern":null,"preventionTips":["Use == / != instead of is / is not in filter lambdas.","Stick to the documented comparison operator subset when authoring filters.","Lint filter lambdas against the supported AST operator set before runtime."],"tags":["azure-cosmos-db","filter","ast","lambda"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}