{"record":{"id":"ef181041bd453ecd","repo":"microsoft/semantic-kernel","slug":"field-node-attr-not-in-data-model-storage-pro-ef1810","errorCode":null,"errorMessage":"Field '{node.attr}' not in data model (storage property names are used).","messagePattern":"Field '(.+?)' not in data model \\(storage property names are used\\)\\.","errorType":"exception","errorClass":"VectorStoreOperationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/mongodb.py","lineNumber":498,"sourceCode":"            case ast.BoolOp():\n                op = node.op  # type: ignore\n                values = [self._lambda_parser(v) for v in node.values]\n                if isinstance(op, ast.And):\n                    return {\"$and\": values}\n                if isinstance(op, ast.Or):\n                    return {\"$or\": values}\n                raise NotImplementedError(f\"Unsupported BoolOp: {type(op)}\")\n            case ast.UnaryOp():\n                match node.op:\n                    case ast.Not():\n                        operand = self._lambda_parser(node.operand)\n                        return {\"$not\": operand}\n                    case ast.UAdd() | ast.USub() | ast.Invert():\n                        raise NotImplementedError(\"Unary +, -, ~ are not supported in MongoDB filters.\")\n            case ast.Attribute():\n                # Only allow attributes that are in the data model\n                if node.attr not in self.definition.storage_names:\n                    raise VectorStoreOperationException(\n                        f\"Field '{node.attr}' not in data model (storage property names are used).\"\n                    )\n                return node.attr\n            case ast.Name():\n                # Only allow names that are in the data model\n                if node.id not in self.definition.storage_names:\n                    raise VectorStoreOperationException(\n                        f\"Field '{node.id}' not in data model (storage property names are used).\"\n                    )\n                return node.id\n            case ast.Constant():\n                return node.value\n        raise NotImplementedError(f\"Unsupported AST node: {type(node)}\")\n\n    @override\n    def _get_record_from_result(self, result: dict[str, Any]) -> dict[str, Any]:\n        return result\n","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/mongodb.py#L480-L516","documentation":"When the MongoDB filter lambda parser encounters an attribute access node (e.g. `x.field_name`), it validates that the attribute name exists in the collection's data model `storage_names`. This VectorStoreOperationException is raised when the attribute name used in the lambda does not match any storage property name registered in the VectorStoreRecordDefinition. The parser uses storage (serialized) names, not the Python property names.","triggerScenarios":"A filter lambda references a field by its Python property name when the storage name differs, or references a field that does not exist on the data model at all. For example the model property is `title` but the storage name is `t`, and the lambda uses `x.title`.","commonSituations":"Using a VectorStoreRecordDefinition with explicit `storage_property_name` overrides where the Python attribute name differs from the storage name. Adding a new field to the filter before adding it to the data model. Typos in field names.","solutions":["Check the VectorStoreRecordDefinition / field definitions and use the storage (serialized) name in the lambda, not the Python attribute name.","Verify the field is declared in the data model with the exact name used in the lambda.","If using storage_name overrides, switch the lambda to reference the storage name."],"exampleFix":"// before (property name 'title' but storage name 't')\ncollection.search(filter=lambda x: x.title == \"foo\")\n// after\ncollection.search(filter=lambda x: x.t == \"foo\")","handlingStrategy":"validation","validationCode":"def validate_filter_fields(func, storage_names: set[str]):\n    import ast, inspect\n    tree = ast.parse(inspect.getsource(func))\n    for node in ast.walk(tree):\n        if isinstance(node, ast.Attribute) and node.attr not in storage_names:\n            raise ValueError(f\"Field '{node.attr}' not in data model storage names: {storage_names}\")","typeGuard":null,"tryCatchPattern":"try:\n    results = await collection.search(filter=my_lambda)\nexcept VectorStoreOperationException as e:\n    if \"not in data model\" in str(e):\n        # check definition.storage_names and use the correct storage name\n        ...","preventionTips":["Cross-reference field names in the lambda against definition.storage_names.","Remember the parser uses storage (serialized) names, not Python property names.","Print definition.storage_names before constructing complex filters."],"tags":["mongodb","filter","data-model","lambda","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}