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
    @abstractmethod

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Read the wrapped message — it contains the underlying pydantic error verbatim, naming the offending field.
  2. Construct AzureAISearchConfig(...) directly in a test to iterate on validation errors quickly, then move the corrected values into the tool factory call.
  3. Check required fields (name, endpoint, index_name, credential) and the interdependent rules (semantic → semantic_config_name; vector → vector_fields).
  4. 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

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


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/5877d8c8c845c0ec. Report an issue: GitHub.