{"record":{"id":"306a1bf750eb55e1","repo":"microsoft/autogen","slug":"vector-fields-must-be-provided-for-vector-search","errorCode":null,"errorMessage":"vector_fields must be provided for vector search","messagePattern":"vector_fields must be provided for vector search","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/azure/_config.py","lineNumber":176,"sourceCode":"            return \"full\"\n\n        return v\n\n    @field_validator(\"top\")\n    def validate_top(cls, v: Optional[int]) -> Optional[int]:\n        \"\"\"Ensure top is a positive integer if provided.\"\"\"\n        if v is not None and v <= 0:\n            raise ValueError(\"top must be a positive integer\")\n        return v\n\n    @model_validator(mode=\"after\")\n    def validate_interdependent_fields(self) -> \"AzureAISearchConfig\":\n        \"\"\"Validate interdependent fields after all fields have been parsed.\"\"\"\n        if self.query_type == \"semantic\" and not self.semantic_config_name:\n            raise ValueError(\"semantic_config_name must be provided when query_type is 'semantic'\")\n\n        if self.query_type == \"vector\" and not self.vector_fields:\n            raise ValueError(\"vector_fields must be provided for vector search\")\n\n        if (\n            self.embedding_provider\n            and self.embedding_provider.lower() == \"azure_openai\"\n            and self.embedding_model\n            and not self.openai_endpoint\n        ):\n            raise ValueError(\"openai_endpoint must be provided for azure_openai embedding provider\")\n\n        return self\n","sourceCodeStart":158,"sourceCodeEnd":187,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/azure/_config.py#L158-L187","documentation":"The config model's second interdependent rule: query_type='vector' requires a non-empty vector_fields list, because the client must know which vector field of the index receives the query embedding. It backs up the factory-level checks (errors 926/927) and also applies to directly constructed or deserialized configs.","triggerScenarios":"AzureAISearchConfig(query_type='vector') (or deserialized config with that query_type) where vector_fields is None, missing, or []; note also that hybrid requires vector_fields via the factory path even though this specific validator keys on 'vector'.","commonSituations":"Hand-editing serialized component configs to enable vector search without adding vector_fields; configs from an older schema version; the index's vector field renamed so the list was emptied.","solutions":["Set vector_fields=['<vector-field-name>'] matching the index's vector field (Collection(Edm.Single)).","Or change query_type to 'simple'/'full' if you only need text search.","Validate saved configs in CI by constructing AzureAISearchConfig from the file contents."],"exampleFix":"# before\nAzureAISearchConfig(name='s', endpoint=ep, index_name='idx', credential=cred, query_type='vector')\n# after\nAzureAISearchConfig(name='s', endpoint=ep, index_name='idx', credential=cred, query_type='vector', vector_fields=['content_vector'])","handlingStrategy":"validation","validationCode":"def vector_fields_rule_ok(cfg_dict: dict) -> bool:\n    if cfg_dict.get('query_type') == 'vector':\n        vf = cfg_dict.get('vector_fields')\n        return isinstance(vf, (list, tuple)) and len(vf) > 0\n    return True","typeGuard":"def vector_fields_present(query_type: str, vector_fields) -> bool:\n    return query_type != 'vector' or (isinstance(vector_fields, (list, tuple)) and len(vector_fields) > 0)","tryCatchPattern":null,"preventionTips":["Whenever query_type is 'vector' or 'hybrid', supply vector_fields matching the index's vector field.","Pin the vector field name in the same config as the ingestion pipeline that writes embeddings.","Validate serialized configs in CI by round-tripping them through AzureAISearchConfig."],"tags":["azure","azure-ai-search","vector-search","configuration","validation","pydantic"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}