{"record":{"id":"8b0a2cd40769347e","repo":"microsoft/autogen","slug":"unexpected-error-initializing-search-client-str","errorCode":null,"errorMessage":"Unexpected error initializing search client: {str(e)}","messagePattern":"Unexpected error initializing search client: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py","lineNumber":413,"sourceCode":"        try:\n            self._client = SearchClient(\n                endpoint=self.search_config.endpoint,\n                index_name=self.search_config.index_name,\n                credential=self.search_config.credential,\n                api_version=self.search_config.api_version,\n            )\n            return self._client\n        except ResourceNotFoundError as e:\n            raise ValueError(f\"Index '{self.search_config.index_name}' not found in Azure AI Search service.\") from e\n        except HttpResponseError as e:\n            if e.status_code == 401:\n                raise ValueError(\"Authentication failed. Please check your credentials.\") from e\n            elif e.status_code == 403:\n                raise ValueError(\"Permission denied to access this index.\") from e\n            else:\n                raise ValueError(f\"Error connecting to Azure AI Search: {str(e)}\") from e\n        except Exception as e:\n            raise ValueError(f\"Unexpected error initializing search client: {str(e)}\") from e\n\n    async def run(\n        self, args: Union[str, Dict[str, Any], SearchQuery], cancellation_token: Optional[CancellationToken] = None\n    ) -> SearchResults:\n        \"\"\"Execute a search against the Azure AI Search index.\n\n        Args:\n            args: Search query text or SearchQuery object\n            cancellation_token: Optional token to cancel the operation\n\n        Returns:\n            SearchResults: Container with search results and metadata\n\n        Raises:\n            ValueError: If the search query is empty or invalid\n            ValueError: If there is an authentication error or other search issue\n            asyncio.CancelledError: If the operation is cancelled\n        \"\"\"","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py#L395-L431","documentation":"Error \"Unexpected error initializing search client: {str(e)}\" thrown in microsoft/autogen.","triggerScenarios":"Thrown at python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py:413 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the inner exception for details"],"exampleFix":"Log the exception and validate config values","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}