{"record":{"id":"d314e879e6c15693","repo":"microsoft/autogen","slug":"index-self-search-config-index-name-not-found-d314e8","errorCode":null,"errorMessage":"Index '{self.search_config.index_name}' not found.","messagePattern":"Index '(.+?)' not found\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py","lineNumber":579,"sourceCode":"                except Exception as e:\n                    logger.warning(f\"Error processing search document: {e}\")\n                    continue\n\n            if self.search_config.enable_caching:\n                self._cache[cache_key] = {\"results\": results, \"timestamp\": time.time()}\n\n            return SearchResults(results=results)\n\n        except asyncio.CancelledError:\n            raise\n        except Exception as e:\n            error_msg = str(e)\n            if isinstance(e, HttpResponseError):\n                if hasattr(e, \"message\") and e.message:\n                    error_msg = e.message\n\n            if \"not found\" in error_msg.lower():\n                raise ValueError(f\"Index '{self.search_config.index_name}' not found.\") from e\n            elif \"unauthorized\" in error_msg.lower() or \"401\" in error_msg:\n                raise ValueError(f\"Authentication failed: {error_msg}\") from e\n            else:\n                raise ValueError(f\"Error from Azure AI Search: {error_msg}\") from e\n\n    def _to_config(self) -> AzureAISearchConfig:\n        \"\"\"Convert the current instance to a configuration object.\"\"\"\n        return self.search_config\n\n    @property\n    def schema(self) -> ToolSchema:\n        \"\"\"Return the schema for the tool.\"\"\"\n        return {\n            \"name\": self.name,\n            \"description\": self.description,\n            \"parameters\": {\n                \"type\": \"object\",\n                \"properties\": {\"query\": {\"type\": \"string\", \"description\": \"Search query text\"}},","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py#L561-L597","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nAzureAISearchTool(name='search', endpoint=endpoint, index_name='hotels', credential=AzureKeyCredential(key))\n// after (match the real index name on the service)\nAzureAISearchTool(name='search', endpoint=endpoint, index_name='hotels-idx', credential=AzureKeyCredential(key))","handlingStrategy":"try-catch","validationCode":"from azure.search.documents.indexes.aio import SearchIndexClient\nfrom azure.core.credentials import AzureKeyCredential\n\nasync def index_exists(endpoint: str, index_name: str, credential) -> bool:\n    client = SearchIndexClient(endpoint=endpoint, credential=credential)\n    try:\n        names = [i async for i in client.list_index_names()]\n        return index_name in names\n    finally:\n        await client.close()","typeGuard":"def is_valid_index_name(name: str) -> bool:\n    return bool(name) and name == name.strip() and ' ' not in name","tryCatchPattern":"try:\n    results = await tool.run(args)\nexcept ValueError as e:\n    if 'not found' in str(e) and tool._to_config().index_name in str(e):\n        # bad index name / wrong service — fix config, do not retry blindly\n        raise\n    raise","preventionTips":["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."],"tags":["azure","azure-ai-search","configuration","index-not-found","runtime"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}