microsoft/semantic-kernel · error · VectorStoreOperationException
Multiplication in filter expressions is only allowed for…
Error message
Multiplication in filter expressions is only allowed for numeric values and bounded sequence repetition.
What it means
Thrown by _safe_mult (in_memory.py:359-360) when `*` is not numeric*numeric and not (int * sequence). Examples: `2.5 * 'x'` (float * str), `'a' * 'b'` (str * str), `x.weight * x.tags` (float * list).
Solutions
- Use an integer repeat count with sequences (int * str/list/tuple).
- Keep multiplication numeric (int/float * int/float) when you mean arithmetic.
- Cast the repeat operand to int().
Example fix
# before VectorSearchOptions(filter="lambda x: x.scale * x.tags") # float * list # after VectorSearchOptions(filter="lambda x: int(x.scale) * x.tags")
Defensive patterns
Strategy: try-catch
Try / catch
try:
results = await collection.search(search_type=SearchType.VECTOR, options=opts)
except VectorStoreOperationException as e:
logger.warning("filter rejected: %s", e.__cause__ or e)
results = None Prevention
- Only repeat sequences with integer counts.
- Reserve * for numeric arithmetic unless you explicitly repeat.
When it happens
Trigger: A filter like `lambda x: x.scale * x.name` (float * str) or `lambda x: x.tags * x.weight` (list * float).
Common situations: Using a floating-point repeat factor; multiplying two sequences; assuming * works like SQL concatenation.
Related errors
- Addition in filter expressions is only allowed for numeric…
- Operator ' ' is only allowed for numeric values in filter…
- Attribute ' ' is not callable in filter expressions.
- Call target node type
- Collection literals in filter expressions exceed the…
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/017fd1b657a0eea3.
Report an issue: GitHub.
Appendix: source
Thrown at python/semantic_kernel/connectors/in_memory.py:359
if isinstance(left, str) and isinstance(right, str):
return self._ensure_sequence_result_size(left, right, lambda a, b: a + b)
if isinstance(left, list) and isinstance(right, list):
return self._ensure_sequence_result_size(left, right, lambda a, b: a + b)
if isinstance(left, tuple) and isinstance(right, tuple):
return self._ensure_sequence_result_size(left, right, lambda a, b: a + b)
raise VectorStoreOperationException(
"Addition in filter expressions is only allowed for numeric values and same-type sequences."
)
def _safe_mult(self, left: Any, right: Any) -> Any:
"""Safely evaluate multiplication."""
if isinstance(left, (int, float)) and isinstance(right, (int, float)):
return left * right
if isinstance(left, int) and isinstance(right, (str, list, tuple)):
return self._safe_repeat(right, left)
if isinstance(right, int) and isinstance(left, (str, list, tuple)):
return self._safe_repeat(left, right)
raise VectorStoreOperationException(
"Multiplication in filter expressions is only allowed for numeric values and bounded sequence repetition."
)
def _safe_repeat(self, value: str | list[Any] | tuple[Any, ...], repeat_count: int) -> Any:
"""Safely repeat a sequence."""
if repeat_count <= 0 or len(value) == 0:
return value * repeat_count
if len(value) > self._max_sequence_repeat_size // repeat_count:
raise VectorStoreOperationException(
"Sequence repetition in filter expressions exceeds the maximum allowed size."
)
return value * repeat_count
def _safe_numeric_operation(
self,
operator_node: ast.AST,
left: Any,
right: Any,View on GitHub (pinned to c028a0c7dc)