microsoft/autogen · error · ValueError
Index '{self.search_config.index_name}' not found.
Error message
Index '{self.search_config.index_name}' not found. What it means
Raised by AzureAISearchTool when the underlying azure.search.documents client throws an exception whose message contains 'not found', most commonly because the index named in AzureAISearchConfig.index_name does not exist on the search service. The original HttpResponseError is chained via `from e`. It is wrapped in a plain ValueError so callers see a config-oriented message instead of an SDK HTTP error.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py:579
except Exception as e:
logger.warning(f"Error processing search document: {e}")
continue
if self.search_config.enable_caching:
self._cache[cache_key] = {"results": results, "timestamp": time.time()}
return SearchResults(results=results)
except asyncio.CancelledError:
raise
except Exception as e:
error_msg = str(e)
if isinstance(e, HttpResponseError):
if hasattr(e, "message") and e.message:
error_msg = e.message
if "not found" in error_msg.lower():
raise ValueError(f"Index '{self.search_config.index_name}' not found.") from e
elif "unauthorized" in error_msg.lower() or "401" in error_msg:
raise ValueError(f"Authentication failed: {error_msg}") from e
else:
raise ValueError(f"Error from Azure AI Search: {error_msg}") from e
def _to_config(self) -> AzureAISearchConfig:
"""Convert the current instance to a configuration object."""
return self.search_config
@property
def schema(self) -> ToolSchema:
"""Return the schema for the tool."""
return {
"name": self.name,
"description": self.description,
"parameters": {
"type": "object",
"properties": {"query": {"type": "string", "description": "Search query text"}},View on GitHub (pinned to 027ecf0a37)
Solutions
- Verify the index exists: az search index list --service-name <service> --resource-group <rg> and compare with the exact index_name passed to the tool.
- Print/inspect search_config.index_name right before use to catch typos, casing, and stray whitespace (e.g. f'[{tool._to_config().index_name}]').
- Confirm the endpoint belongs to the search service that actually hosts the index.
- If the index was deleted or not yet created, (re)create and populate it before running the tool.
- In multi-tenant setups, drive index_name from configuration per environment instead of hard-coding it.
Example fix
// before AzureAISearchTool(name='search', endpoint=endpoint, index_name='hotels', credential=AzureKeyCredential(key)) // after (match the real index name on the service) AzureAISearchTool(name='search', endpoint=endpoint, index_name='hotels-idx', credential=AzureKeyCredential(key))
Defensive patterns
Strategy: try-catch
Validate before calling
from azure.search.documents.indexes.aio import SearchIndexClient
from azure.core.credentials import AzureKeyCredential
async def index_exists(endpoint: str, index_name: str, credential) -> bool:
client = SearchIndexClient(endpoint=endpoint, credential=credential)
try:
names = [i async for i in client.list_index_names()]
return index_name in names
finally:
await client.close() Type guard
def is_valid_index_name(name: str) -> bool:
return bool(name) and name == name.strip() and ' ' not in name Try / catch
try:
results = await tool.run(args)
except ValueError as e:
if 'not found' in str(e) and tool._to_config().index_name in str(e):
# bad index name / wrong service — fix config, do not retry blindly
raise
raise Prevention
- List index names at startup and assert your configured index_name is present before the first agent run.
- Drive index_name, endpoint, and credential from one environment-scoped config so they cannot drift between services.
- Log tool._to_config() once at construction to catch typos early.
When it happens
Trigger: Calling the tool's run/execution path (e.g. agent invokes the Azure AI Search tool) where SearchClient.search() fails with a 404/ResourceNotFound response; passing index_name='hotels' when the service only has 'hotels-idx'; using an index name with typos, wrong casing, or one that was deleted; querying a different (wrong) search service whose endpoint hosts no such index.
Common situations: Index name copied from another environment (dev index name used against prod service), index deleted or never created before running the agent, endpoint pointing at a different Azure AI Search resource, or a trailing-space/typo in index_name in the constructor or config dict.
Related errors
- Invalid server URL configuration
- Error from Azure AI Search: {error_msg}
- Invalid configuration: {str(e)}
- vector_fields must contain at least one field name for vecto
- vector_fields must contain at least one field name for hybri
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/d314e879e6c15693.
Report an issue: GitHub.