microsoft/autogen · error · ValueError
Invalid configuration: {str(e)}
Error message
Invalid configuration: {str(e)} What it means
After the cheap credential pre-checks, _validate_config trial-constructs AzureAISearchConfig(**config_dict). If the pydantic model rejects any field (missing required field, wrong type, endpoint not http(s), top <= 0, semantic/vector interdependent rules), the pydantic ValidationError is wrapped into ValueError('Invalid configuration: <details>').
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py:631
result_strings.append(f"Result {i} (Score: {result.score:.2f}): {content_str}")
return "\n".join(result_strings)
@classmethod
def _validate_config(
cls, config_dict: Dict[str, Any], search_type: Literal["full_text", "vector", "hybrid"]
) -> None:
"""Validate configuration for specific search types."""
credential = config_dict.get("credential")
if isinstance(credential, str):
raise TypeError("Credential must be AzureKeyCredential, AsyncTokenCredential, or a valid dict")
if isinstance(credential, dict) and "api_key" not in credential:
raise ValueError("If credential is a dict, it must contain an 'api_key' key")
try:
_ = AzureAISearchConfig(**config_dict)
except Exception as e:
raise ValueError(f"Invalid configuration: {str(e)}") from e
if search_type == "vector":
vector_fields = config_dict.get("vector_fields")
if not vector_fields or len(vector_fields) == 0:
raise ValueError("vector_fields must contain at least one field name for vector search")
elif search_type == "hybrid":
vector_fields = config_dict.get("vector_fields")
search_fields = config_dict.get("search_fields")
if not vector_fields or len(vector_fields) == 0:
raise ValueError("vector_fields must contain at least one field name for hybrid search")
if not search_fields or len(search_fields) == 0:
raise ValueError("search_fields must contain at least one field name for hybrid search")
@classmethod
@abstractmethodView on GitHub (pinned to 027ecf0a37)
Solutions
- Read the wrapped message — it contains the underlying pydantic error verbatim, naming the offending field.
- Construct AzureAISearchConfig(...) directly in a test to iterate on validation errors quickly, then move the corrected values into the tool factory call.
- Check required fields (name, endpoint, index_name, credential) and the interdependent rules (semantic → semantic_config_name; vector → vector_fields).
- After upgrading autogen-ext, diff the factory signature and AzureAISearchConfig field list for renames.
Example fix
# before AzureAISearchTool(name='s', endpoint='svc.search.windows.net', index_name='idx', credential=cred) # after (endpoint needs scheme; error text will say exactly which field failed) AzureAISearchTool(name='s', endpoint='https://svc.search.windows.net', index_name='idx', credential=cred)
Defensive patterns
Strategy: validation
Validate before calling
from autogen_ext.tools.azure._config import AzureAISearchConfig
def config_dict_is_valid(config_dict: dict) -> bool:
try:
AzureAISearchConfig(**config_dict)
return True
except Exception:
return False Try / catch
try:
tool = await AzureAISearchTool.create_(...)
except ValueError as e:
if str(e).startswith('Invalid configuration:'):
# str(e) embeds the pydantic error naming the bad field — log and surface it
log.error('Bad search tool config: %s', e)
raise Prevention
- Dry-run AzureAISearchConfig(**kwargs) in unit tests for every config shape you ship.
- Type your config dicts (TypedDict/dataclass) instead of building ad-hoc dicts at call sites.
- Check required fields (name, endpoint, index_name, credential) and interdependent rules before calling factories.
When it happens
Trigger: Any factory constructor call whose kwargs fail AzureAISearchConfig validation: missing name/endpoint/index_name, endpoint without http(s)://, top=0 or negative, query_type='semantic' without semantic_config_name, query_type='vector' without vector_fields, wrong type for a list field.
Common situations: Typos in kwarg names (e.g. index instead of index_name) that become unexpected/missing fields; endpoint passed without scheme; drift between the factory signature and the config model after a library upgrade.
Related errors
- endpoint must be a valid URL starting with http:// or https:
- top must be a positive integer
- semantic_config_name must be provided when query_type is 'se
- vector_fields must be provided for vector search
- vector_fields must contain at least one field name for vecto
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/5877d8c8c845c0ec.
Report an issue: GitHub.