{"record":{"id":"dd8316fdca6901bd","repo":"microsoft/autogen","slug":"vector-fields-must-contain-at-least-one-field-name","errorCode":null,"errorMessage":"vector_fields must contain at least one field name for vector search","messagePattern":"vector_fields must contain at least one field name for vector search","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py","lineNumber":636,"sourceCode":"    def _validate_config(\n        cls, config_dict: Dict[str, Any], search_type: Literal[\"full_text\", \"vector\", \"hybrid\"]\n    ) -> None:\n        \"\"\"Validate configuration for specific search types.\"\"\"\n        credential = config_dict.get(\"credential\")\n        if isinstance(credential, str):\n            raise TypeError(\"Credential must be AzureKeyCredential, AsyncTokenCredential, or a valid dict\")\n        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        \"\"\"","sourceCodeStart":618,"sourceCodeEnd":654,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py#L618-L654","documentation":"For the vector search factory, _validate_config requires config_dict['vector_fields'] to be a non-empty list — the client-side embedding is matched to the index's vector field by this name, so vector search cannot be constructed without it.","triggerScenarios":"Calling the vector factory (e.g. AzureAISearchTool.for_vector_search or the vector constructor around line 933's config) without vector_fields, with vector_fields=None, or with vector_fields=[].","commonSituations":"Copy-pasting the full-text constructor example and switching query_type to 'vector' without adding vector_fields; assuming the tool auto-detects the vector field; index renamed its vector column (content_vector vs embedding).","solutions":["Pass the exact vector field name defined in the index: vector_fields=['content_vector'].","Check the index definition (Fields section in the portal or az search index show) for the field of type Collection(Edm.Single) marked as a vector field.","For hybrid search remember search_fields is also required in addition to vector_fields."],"exampleFix":"# before\ntool = await AzureAISearchTool.create_vector_search_tool(name='v', endpoint=ep, index_name='idx', credential=cred, embedding_provider='openai', embedding_model='text-embedding-ada-002', openai_api_key=k)\n# after\ntool = await AzureAISearchTool.create_vector_search_tool(name='v', endpoint=ep, index_name='idx', credential=cred, vector_fields=['content_vector'], embedding_provider='openai', embedding_model='text-embedding-ada-002', openai_api_key=k)","handlingStrategy":"validation","validationCode":"def vector_config_ready(config_dict: dict) -> bool:\n    vf = config_dict.get('vector_fields')\n    return isinstance(vf, list) and len(vf) > 0 and all(isinstance(f, str) and f for f in vf)","typeGuard":"def has_vector_fields(vector_fields) -> bool:\n    return isinstance(vector_fields, (list, tuple)) and len(vector_fields) > 0","tryCatchPattern":null,"preventionTips":["Keep vector_fields next to query_type='vector' in one config block so they change together.","Record the index's vector field name in the same place you define the ingestion pipeline that writes it.","Assert vector_fields non-empty in config tests."],"tags":["azure","azure-ai-search","vector-search","configuration","validation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}