{"record":{"id":"20ddc3b5fc415513","repo":"microsoft/autogen","slug":"vector-fields-must-contain-at-least-one-field-name-20ddc3","errorCode":null,"errorMessage":"vector_fields must contain at least one field name for hybrid search","messagePattern":"vector_fields must contain at least one field name for hybrid search","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py","lineNumber":643,"sourceCode":"        if isinstance(credential, dict) and \"api_key\" not in credential:\n            raise ValueError(\"If credential is a dict, it must contain an 'api_key' key\")\n\n        try:\n            _ = AzureAISearchConfig(**config_dict)\n        except Exception as e:\n            raise ValueError(f\"Invalid configuration: {str(e)}\") from e\n\n        if search_type == \"vector\":\n            vector_fields = config_dict.get(\"vector_fields\")\n            if not vector_fields or len(vector_fields) == 0:\n                raise ValueError(\"vector_fields must contain at least one field name for vector search\")\n\n        elif search_type == \"hybrid\":\n            vector_fields = config_dict.get(\"vector_fields\")\n            search_fields = config_dict.get(\"search_fields\")\n\n            if not vector_fields or len(vector_fields) == 0:\n                raise ValueError(\"vector_fields must contain at least one field name for hybrid search\")\n\n            if not search_fields or len(search_fields) == 0:\n                raise ValueError(\"search_fields must contain at least one field name for hybrid search\")\n\n    @classmethod\n    @abstractmethod\n    def _from_config(cls, config: AzureAISearchConfig) -> \"BaseAzureAISearchTool\":\n        \"\"\"Create a tool instance from a configuration object.\n\n        This is an abstract method that must be implemented by subclasses.\n        \"\"\"\n        if cls is BaseAzureAISearchTool:\n            raise NotImplementedError(\n                \"BaseAzureAISearchTool is an abstract base class and cannot be instantiated directly. \"\n                \"Use a concrete implementation like AzureAISearchTool.\"\n            )\n        raise NotImplementedError(\"Subclasses must implement _from_config\")\n","sourceCodeStart":625,"sourceCodeEnd":661,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py#L625-L661","documentation":"Same rule as 926 but for the hybrid factory: hybrid search sends both a vector query and full-text terms, so vector_fields must name at least one vector field of the index before the tool can be constructed.","triggerScenarios":"Calling the hybrid search factory (constructor near line 1109) with vector_fields omitted, None, or an empty list.","commonSituations":"Upgrading a full-text tool to hybrid by only changing query_type and adding search_fields, forgetting the vector side; index vector field renamed during a re-ingestion.","solutions":["Pass vector_fields=['<vector-field-name>'] matching the index's Collection(Edm.Single) field.","Also pass non-empty search_fields (hybrid requires both — see error 928).","Verify both field names against the index schema before constructing the tool."],"exampleFix":"# before\ntool = await AzureAISearchTool.create_hybrid_search_tool(name='h', endpoint=ep, index_name='idx', credential=cred, search_fields=['content'])\n# after\ntool = await AzureAISearchTool.create_hybrid_search_tool(name='h', endpoint=ep, index_name='idx', credential=cred, vector_fields=['content_vector'], search_fields=['content'])","handlingStrategy":"validation","validationCode":"def hybrid_config_ready(config_dict: dict) -> bool:\n    vf = config_dict.get('vector_fields')\n    sf = config_dict.get('search_fields')\n    return bool(vf) and len(vf) > 0 and bool(sf) and len(sf) > 0","typeGuard":"def hybrid_fields_present(vector_fields, search_fields) -> bool:\n    return (\n        isinstance(vector_fields, (list, tuple)) and len(vector_fields) > 0\n        and isinstance(search_fields, (list, tuple)) and len(search_fields) > 0\n    )","tryCatchPattern":null,"preventionTips":["Treat (vector_fields, search_fields) as an atomic pair for hybrid search in config templates.","Validate both lists against the index schema (one vector field, at least one searchable text field).","Add a unit test that every hybrid tool config has both fields non-empty."],"tags":["azure","azure-ai-search","hybrid-search","vector-search","configuration","validation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}