microsoft/semantic-kernel · error · VectorStoreOperationException

Field '{node.attr}' not in data model (storage property name

Error message

Field '{node.attr}' not in data model (storage property names are used).

What it means

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.

Source

Thrown at python/semantic_kernel/connectors/mongodb.py:498

            case ast.BoolOp():
                op = node.op  # type: ignore
                values = [self._lambda_parser(v) for v in node.values]
                if isinstance(op, ast.And):
                    return {"$and": values}
                if isinstance(op, ast.Or):
                    return {"$or": values}
                raise NotImplementedError(f"Unsupported BoolOp: {type(op)}")
            case ast.UnaryOp():
                match node.op:
                    case ast.Not():
                        operand = self._lambda_parser(node.operand)
                        return {"$not": operand}
                    case ast.UAdd() | ast.USub() | ast.Invert():
                        raise NotImplementedError("Unary +, -, ~ are not supported in MongoDB filters.")
            case ast.Attribute():
                # Only allow attributes that are in the data model
                if node.attr not in self.definition.storage_names:
                    raise VectorStoreOperationException(
                        f"Field '{node.attr}' not in data model (storage property names are used)."
                    )
                return node.attr
            case ast.Name():
                # Only allow names that are in the data model
                if node.id not in self.definition.storage_names:
                    raise VectorStoreOperationException(
                        f"Field '{node.id}' not in data model (storage property names are used)."
                    )
                return node.id
            case ast.Constant():
                return node.value
        raise NotImplementedError(f"Unsupported AST node: {type(node)}")

    @override
    def _get_record_from_result(self, result: dict[str, Any]) -> dict[str, Any]:
        return result

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Check the VectorStoreRecordDefinition / field definitions and use the storage (serialized) name in the lambda, not the Python attribute name.
  2. Verify the field is declared in the data model with the exact name used in the lambda.
  3. If using storage_name overrides, switch the lambda to reference the storage name.

Example fix

// before (property name 'title' but storage name 't')
collection.search(filter=lambda x: x.title == "foo")
// after
collection.search(filter=lambda x: x.t == "foo")
Defensive patterns

Strategy: validation

Validate before calling

def validate_filter_fields(func, storage_names: set[str]):
    import ast, inspect
    tree = ast.parse(inspect.getsource(func))
    for node in ast.walk(tree):
        if isinstance(node, ast.Attribute) and node.attr not in storage_names:
            raise ValueError(f"Field '{node.attr}' not in data model storage names: {storage_names}")

Try / catch

try:
    results = await collection.search(filter=my_lambda)
except VectorStoreOperationException as e:
    if "not in data model" in str(e):
        # check definition.storage_names and use the correct storage name
        ...

Prevention

When it happens

Trigger: 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`.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/ef181041bd453ecd. Report an issue: GitHub.