{"record":{"id":"8ae7c985613665a5","repo":"microsoft/semantic-kernel","slug":"values-for-filter-key-key-are-not-lists","errorCode":null,"errorMessage":"Values for filter key '{key}' are not lists.","messagePattern":"Values for filter key '(.+?)' are not lists\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/function_calling_utils.py","lineNumber":97,"sourceCode":"\ndef _combine_filter_dicts(*dicts: dict[str, list[str]]) -> dict:\n    \"\"\"Combine multiple filter dictionaries with list values into one dictionary.\n\n    This method is ensuring unique values while preserving order.\n    \"\"\"\n    combined_filters = {}\n\n    keys = set().union(*(d.keys() for d in dicts))\n\n    for key in keys:\n        combined_functions: OrderedDict[str, None] = OrderedDict()\n        for d in dicts:\n            if key in d:\n                if isinstance(d[key], list):\n                    for item in d[key]:\n                        combined_functions[item] = None\n                else:\n                    raise ServiceInitializationError(f\"Values for filter key '{key}' are not lists.\")\n        combined_filters[key] = list(combined_functions.keys())\n\n    return combined_filters\n\n\ndef merge_function_results(\n    messages: list[\"ChatMessageContent\"],\n) -> list[\"ChatMessageContent\"]:\n    \"\"\"Combine multiple function result content types to one chat message content type.\n\n    This method combines the FunctionResultContent items from separate ChatMessageContent messages,\n    and is used in the event that the `context.terminate = True` condition is met.\n    \"\"\"\n    from semantic_kernel.contents.chat_message_content import ChatMessageContent\n    from semantic_kernel.contents.function_result_content import FunctionResultContent\n\n    items: list[Any] = []\n    for message in messages:","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/function_calling_utils.py#L79-L115","documentation":"Raised by the internal _combine_filter_dicts helper when merging function-choice filter dictionaries: it expects every value to be a list of strings, but encountered a non-list value for a given key. The helper unions filter keys across dicts and deduplicates list entries, so a scalar value cannot be merged.","triggerScenarios":"FunctionChoiceBehavior.from_dict or any caller of _combine_filter_dicts passing filter dicts whose values are not lists, e.g. {'included_functions': 'my-func'} instead of {'included_functions': ['my-func']}.","commonSituations":"Hand-building a filters dict with scalar values; deserializing a config/YAML where a single function name was given as a string rather than a one-element list; merging a user-supplied filters dict that did not validate shapes.","solutions":["Ensure every filter value is a list of strings, e.g. {'included_functions': ['plugin-function']}.","Normalize scalar inputs to single-element lists before calling FunctionChoiceBehavior.from_dict.","Validate the filters dict shape before constructing the behavior."],"exampleFix":"# before\nfilters = {\"included_functions\": \"search-web\"}\nbehavior = FunctionChoiceBehavior.from_dict({\"type\": \"auto\", \"filters\": filters})\n# after\nfilters = {\"included_functions\": [\"search-web\"]}\nbehavior = FunctionChoiceBehavior.from_dict({\"type\": \"auto\", \"filters\": filters})","handlingStrategy":"validation","validationCode":"def filters_values_are_lists(filters: dict) -> bool:\n    return all(isinstance(v, list) and all(isinstance(x, str) for x in v) for v in filters.values())","typeGuard":"from typing import Any\n\ndef is_valid_filter_dict(filters: Any) -> bool:\n    return isinstance(filters, dict) and all(isinstance(v, list) for v in filters.values())","tryCatchPattern":"from semantic_kernel.exceptions.service_exceptions import ServiceInitializationError\n\ntry:\n    behavior = FunctionChoiceBehavior.from_dict({\"type\": \"auto\", \"filters\": filters})\nexcept ServiceInitializationError as e:\n    if \"are not lists\" in str(e):\n        filters = {k: ([v] if isinstance(v, str) else v) for k, v in filters.items()}\n        behavior = FunctionChoiceBehavior.from_dict({\"type\": \"auto\", \"filters\": filters})\n    else:\n        raise","preventionTips":["Always use list-of-strings values in function-choice filter dicts.","Normalize scalar strings to single-element lists before constructing the behavior.","Validate the filter dict shape before passing to from_dict."],"tags":["function-calling","filters","configuration","validation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}