{"record":{"id":"9e5ea25cc9c78c47","repo":"microsoft/semantic-kernel","slug":"field-node-attr-not-in-data-model-storage-pro","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/azure_cosmos_db.py","lineNumber":949,"sourceCode":"                    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(\n                            f\"Field '{node.attr}' not in data model (storage property names are used).\"\n                        )\n                    return f\"c.{node.attr}\"\n                case ast.Name():\n                    # Could be a variable or constant; not supported\n                    raise NotImplementedError(\"Constants or variables are not supported, use a value or attribute.\")\n                case ast.Constant():\n                    # Bind strings as query parameters to avoid SQL injection. Numbers and null\n                    # cannot carry injection, so they are inlined.\n                    if isinstance(node.value, str):\n                        name = f\"@filter_p{len(parameters)}\"\n                        parameters.append({\"name\": name, \"value\": node.value})\n                        return name\n                    if isinstance(node.value, (float, int)):\n                        return str(node.value)\n                    if node.value is None:\n                        return \"null\"\n                    raise NotImplementedError(f\"Unsupported constant type: {type(node.value)}\")","sourceCodeStart":931,"sourceCodeEnd":967,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/azure_cosmos_db.py#L931-L967","documentation":"When the AST translator encounters an attribute access (e.g. x.field_name), it validates that the attribute name is a known storage property name in the data model definition before emitting c.<field>. If node.attr is not in self.definition.storage_names it raises a VectorStoreOperationException. This protects against generating SQL that references a non-existent column and stops SQL-injection-shaped field names early.","triggerScenarios":"A filter lambda references a field by its Python/property name when the data model stores it under a different storage_name, or references a field that simply does not exist on the model, or a typo in the attribute name.","commonSituations":"The data model uses an alias (e.g. Python attr 'description' stored as 'desc') and the filter uses the wrong name; or you filter on a field that exists in the source dict but was not declared in the VectorStoreRecordDefinition fields.","solutions":["Use the exact storage property name that the data model declares; check self.definition.storage_names (or the field's storage_name) for the correct spelling.","Declare the missing field in the VectorStoreRecordDefinition so it becomes a valid filterable attribute.","Fix typos in the lambda attribute to match the model field name exactly."],"exampleFix":"// before\n# data model stores the text as 'content', not 'description'\noptions = VectorSearchOptions(filter=lambda x: x.description == \"news\")\n// after\noptions = VectorSearchOptions(filter=lambda x: x.content == \"news\")\n","handlingStrategy":"validation","validationCode":"valid = set(store.definition.storage_names)\n# before searching:\nfor node in ast.walk(ast.parse(filter_src, mode=\"eval\")):\n    if isinstance(node, ast.Attribute) and node.attr not in valid:\n        raise ValueError(f\"Filter references unknown field: {node.attr}\")","typeGuard":"def is_known_field(store, attr: str) -> bool:\n    return attr in store.definition.storage_names","tryCatchPattern":null,"preventionTips":["Use storage property names exactly as declared in the data model.","Declare all filterable fields in the VectorStoreRecordDefinition.","Validate referenced field names against storage_names before querying."],"tags":["azure-cosmos-db","filter","data-model","ast"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}