{"record":{"id":"f4d247ebede99c7a","repo":"microsoft/autogen","slug":"semantic-config-name-must-be-provided-when-query-t","errorCode":null,"errorMessage":"semantic_config_name must be provided when query_type is 'semantic'","messagePattern":"semantic_config_name must be provided when query_type is 'semantic'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/azure/_config.py","lineNumber":173,"sourceCode":"            return \"simple\"\n\n        if isinstance(v, str) and v.lower() == \"fulltext\":\n            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":155,"sourceCodeEnd":187,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/azure/_config.py#L155-L187","documentation":"AzureAISearchConfig's model_validator (mode='after') enforces interdependent rules once all fields are parsed. The first rule: query_type='semantic' requires semantic_config_name. This is the config-level backstop behind the factory-level checks (errors 932/934) and also fires when configs are deserialized from component configs/JSON rather than built via factories.","triggerScenarios":"Constructing or deserializing AzureAISearchConfig(query_type='semantic') without semantic_config_name — including loading a saved component config where the field was dropped, or programmatically mutating a config dict.","commonSituations":"Round-tripping tool configs through the autogen component config system with an older config that predates semantic support; hand-written YAML/JSON component definitions missing the field; switching query_type in serialized config without updating companions.","solutions":["Add semantic_config_name matching a semantic configuration defined on the index.","Change query_type to 'simple'/'full' if semantic ranking is not needed.","When editing serialized component configs, re-validate by constructing AzureAISearchConfig(**dict) in a test before loading it in the agent."],"exampleFix":"# before\nAzureAISearchConfig(name='s', endpoint=ep, index_name='idx', credential=cred, query_type='semantic')\n# after\nAzureAISearchConfig(name='s', endpoint=ep, index_name='idx', credential=cred, query_type='semantic', semantic_config_name='my-semantic-config')","handlingStrategy":"validation","validationCode":"def config_interdependent_rules_ok(cfg_dict: dict) -> bool:\n    if cfg_dict.get('query_type') == 'semantic' and not cfg_dict.get('semantic_config_name'):\n        return False\n    if cfg_dict.get('query_type') == 'vector' and not cfg_dict.get('vector_fields'):\n        return False\n    return True","typeGuard":"def semantic_pair_valid(query_type, semantic_config_name) -> bool:\n    return query_type != 'semantic' or bool(semantic_config_name)","tryCatchPattern":"try:\n    cfg = AzureAISearchConfig(**config_dict)\nexcept ValueError as e:  # pydantic ValidationError\n    if 'semantic_config_name' in str(e):\n        config_dict.setdefault('semantic_config_name', 'default')\n        cfg = AzureAISearchConfig(**config_dict)\n    else:\n        raise","preventionTips":["Re-validate saved/deserialized component configs by constructing AzureAISearchConfig in tests.","Keep query_type and its required companions (semantic_config_name, vector_fields) in one config template.","When enabling semantic search, first confirm a semantic configuration exists on the index."],"tags":["azure","azure-ai-search","semantic-search","configuration","validation","pydantic"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}