{"record":{"id":"1c246133ba65b38c","repo":"microsoft/autogen","slug":"error-from-azure-ai-search-error-msg","errorCode":null,"errorMessage":"Error from Azure AI Search: {error_msg}","messagePattern":"Error from Azure AI Search: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py","lineNumber":583,"sourceCode":"            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\"}},\n                \"required\": [\"query\"],\n                \"additionalProperties\": False,\n            },\n            \"strict\": True,","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py#L565-L601","documentation":"The catch-all branch of the tool's error handling: any exception from the Azure AI Search SDK that is neither 'not found' nor 'unauthorized/401' is re-raised as ValueError('Error from Azure AI Search: <original message>'). The original exception is preserved as __cause__, so `except ValueError as e: e.__cause__` still exposes the HttpResponseError details.","triggerScenarios":"Any SDK/runtime failure during the search call: HTTP 400 from a malformed OData filter or invalid search_fields/select_fields (nonexistent field names), HTTP 429 throttling, HTTP 5xx service errors, semantic query against an index without a semantic configuration, wrong api_version, network/DNS failures, or a vector query against a non-vector field.","commonSituations":"Bad OData filter syntax in hybrid search; select_fields listing fields not in the index; api_version set to a preview version that does not support the used feature; search service throttling under load; semantic ranking requested on a basic tier that does not support it.","solutions":["Inspect the chained cause: except ValueError as e: print(e.__cause__) — the HttpResponseError status code and message identify the real problem.","Fix per status: 400 → validate filter syntax and field names against the index definition; 429 → add retry/backoff or reduce request rate; 5xx → retry with backoff.","Confirm api_version (default DEFAULT_API_VERSION) supports the features you use (semantic, vector) for your service tier.","Test the same query with a minimal standalone SearchClient script to isolate whether the issue is the tool config or the service/index itself."],"exampleFix":"# before\nresults = await tool.run(args)\n# after (surface the underlying SDK error)\ntry:\n    results = await tool.run(args)\nexcept ValueError as e:\n    cause = e.__cause__\n    status = getattr(cause, 'status_code', None)\n    raise RuntimeError(f'Search failed (HTTP {status}): {cause}') from cause","handlingStrategy":"retry","validationCode":null,"typeGuard":"def is_throttling(cause) -> bool:\n    return getattr(cause, 'status_code', None) == 429","tryCatchPattern":"import asyncio\n\nasync def run_search_with_retry(tool, args, attempts=3):\n    for i in range(attempts):\n        try:\n            return await tool.run(args)\n        except ValueError as e:\n            cause = e.__cause__\n            status = getattr(cause, 'status_code', None)\n            if status in (429, 500, 503) and i < attempts - 1:\n                await asyncio.sleep(2 ** i)\n                continue\n            raise","preventionTips":["Always inspect e.__cause__ — the real HttpResponseError status code and message are there.","Validate OData filter strings and field names (search_fields/select_fields) against the index schema before running the agent.","Add retry with exponential backoff for 429/5xx; fix 400s in config instead of retrying."],"tags":["azure","azure-ai-search","runtime","catch-all","http-error"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}