microsoft/semantic-kernel · error · VectorStoreOperationException
Field '{node.id}' not in data model (storage property names
Error message
Field '{node.id}' not in data model (storage property names are used). What it means
When the MongoDB filter lambda parser encounters a bare Name node (e.g. using a variable or field reference as `field` instead of `x.field`), it validates that the name exists in the data model's `storage_names`. This VectorStoreOperationException fires when the name does not match any storage property. This guards against referencing undefined fields or variables that are not part of the data model.
Source
Thrown at python/semantic_kernel/connectors/mongodb.py:505
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
@override
def _get_score_from_result(self, result: dict[str, Any]) -> float | None:
return result.get(MONGODB_SCORE_FIELD)
@override
async def __aexit__(self, exc_type, exc_value, traceback) -> None:
"""Exit the context manager."""View on GitHub (pinned to c028a0c7dc)
Solutions
- Ensure every field reference in the lambda uses attribute-access form `x.field_name` with the lambda parameter prefix.
- Verify the referenced name matches a storage name in the VectorStoreRecordDefinition.
- Use constants via ast.Constant (literal values) rather than bare variable names inside the lambda.
Example fix
// before (bare name 'status' instead of attribute access) collection.search(filter=lambda x: status == "active") // after collection.search(filter=lambda x: x.status == "active")
Defensive patterns
Strategy: validation
Validate before calling
def validate_filter_names(func, storage_names: set[str]):
import ast, inspect
tree = ast.parse(inspect.getsource(func))
for node in ast.walk(tree):
if isinstance(node, ast.Name) and node.id not in storage_names:
# bare name not in data model — likely a missing 'x.' prefix
raise ValueError(f"Name '{node.id}' not in data model; did you forget the lambda parameter prefix?") Try / catch
try:
results = await collection.search(filter=my_lambda)
except VectorStoreOperationException as e:
if "not in data model" in str(e):
# prefix all field references with the lambda parameter (e.g. x.field)
... Prevention
- Always prefix field references in the lambda with the parameter name (e.g. x.field, not field).
- Use only literal constants for comparison values, not bare variable names.
- Validate field names against definition.storage_names before querying.
When it happens
Trigger: The filter lambda references a bare name (not an attribute access) that is not in the data model storage names, for example `lambda x: my_field == 1` where `my_field` is neither a data model field nor prefixed with the lambda parameter.
Common situations: Developer forgets to prefix the field with the lambda parameter (e.g. writes `field` instead of `x.field`). Developer references a local variable or constant by name inside the lambda. Storage name differs from the referenced name.
Related errors
- Field '{node.attr}' not in data model (storage property name
- Unsupported operator: {type(op)}
- Unsupported BoolOp: {type(op)}
- Unary +, -, ~ are not supported in MongoDB filters.
- Unsupported AST node: {type(node)}
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/1b00a1fe0a0dceb4.
Report an issue: GitHub.