{"record":{"id":"c69273a4293018c6","repo":"microsoft/semantic-kernel","slug":"invalid-query-type-raw-query-type-in-spec","errorCode":null,"errorMessage":"Invalid query_type '{raw_query_type}' in: {spec}","messagePattern":"Invalid query_type '(.+?)' in: (.+?)","errorType":"validation","errorClass":"AgentInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/azure_ai/azure_ai_agent.py","lineNumber":117,"sourceCode":"@_register_tool(\"azure_ai_search\")\ndef _azure_ai_search(spec: ToolSpec) -> AzureAISearchTool:\n    opts = spec.options or {}\n\n    connections = opts.get(\"tool_connections\")\n    if not connections or not isinstance(connections, list) or not connections[0]:\n        raise AgentInitializationException(f\"Missing or malformed 'tool_connections' in: {spec}\")\n    conn_id = connections[0]\n\n    index_name = opts.get(\"index_name\")\n    if not index_name or not isinstance(index_name, str):\n        raise AgentInitializationException(f\"Missing or malformed 'index_name' in: {spec}\")\n\n    raw_query_type = opts.get(\"query_type\", AzureAISearchQueryType.SIMPLE)\n    if type(raw_query_type) is str:\n        try:\n            query_type = AzureAISearchQueryType(raw_query_type.lower())\n        except ValueError:\n            raise AgentInitializationException(f\"Invalid query_type '{raw_query_type}' in: {spec}\")\n    else:\n        query_type = raw_query_type\n\n    filter_expr = opts.get(\"filter\", \"\")\n\n    top_k = opts.get(\"top_k\", 5)\n    if not isinstance(top_k, int):\n        raise AgentInitializationException(f\"'top_k' must be an integer in: {spec}\")\n\n    return AzureAISearchTool(\n        index_connection_id=conn_id,\n        index_name=index_name,\n        query_type=query_type,\n        filter=filter_expr,\n        top_k=top_k,\n    )\n\n","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/azure_ai/azure_ai_agent.py#L99-L135","documentation":"Raised when an azure_ai_search tool spec's query_type string does not map to any AzureAISearchQueryType enum member (after lowercasing). Valid members are typically simple, full, semantic, vector, vector_simple_hybrid, vector_semantic_hybrid.","triggerScenarios":"Setting query_type to an unrecognized string (e.g. 'hybrid', 'keyword', 'fuzzy') in the declarative spec; passing a value valid for the REST API but not the SDK enum.","commonSituations":"Developer guesses a query type name; version skew between the enum members the installed SDK knows and the Azure docs being followed.","solutions":["Set query_type to a valid AzureAISearchQueryType member string: simple, full, semantic, vector, vector_simple_hybrid, or vector_semantic_hybrid.","Omit query_type to accept the default (SIMPLE) when a basic search is acceptable.","Inspect AzureAISearchQueryType.__members__ in your installed version for the authoritative list."],"exampleFix":"// before\noptions:\n  query_type: hybrid\n\n// after\noptions:\n  query_type: vector_simple_hybrid\n# or omit for default SIMPLE","handlingStrategy":"validation","validationCode":"from semantic_kernel.connectors.ai.azure_ai.azure_ai_search_query_type import AzureAISearchQueryType\n\ndef validate_query_type(raw):\n    if isinstance(raw, str) and raw.lower() not in {m.value for m in AzureAISearchQueryType}:\n        raise ValueError(f\"query_type '{raw}' is invalid\")\n    return raw","typeGuard":"def is_valid_query_type(raw) -> bool:\n    if not isinstance(raw, str):\n        return True\n    return raw.lower() in {m.value for m in AzureAISearchQueryType}","tryCatchPattern":null,"preventionTips":["Reference AzureAISearchQueryType members by enum rather than hardcoded strings.","Print AzureAISearchQueryType.__members__ once to confirm valid values for the installed version."],"tags":["azure-ai-agent","declarative-spec","azure-ai-search","query-type"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}