{"record":{"id":"1a6cbd86cbe2bafb","repo":"microsoft/markitdown","slug":"failed-to-resolve-analyzer-analyzer-id-exc","errorCode":null,"errorMessage":"Failed to resolve analyzer '{analyzer_id}': {exc}","messagePattern":"Failed to resolve analyzer '(.+?)': (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/markitdown/src/markitdown/converters/_cu_converter.py","lineNumber":422,"sourceCode":"    Args:\n        client: A ``ContentUnderstandingClient`` instance.\n        analyzer_id: The analyzer ID to resolve.\n\n    Returns:\n        Modality string (\"document\", \"image\", \"audio\", or \"video\").\n\n    Raises:\n        ValueError: If ``get_analyzer()`` fails.\n    \"\"\"\n    # Known prebuilt — use cache, no API call\n    if analyzer_id in _KNOWN_PREBUILT_MODALITY:\n        return _KNOWN_PREBUILT_MODALITY[analyzer_id]\n\n    # Unknown prebuilt or custom analyzer — call get_analyzer()\n    try:\n        analyzer_info = client.get_analyzer(analyzer_id)\n    except Exception as exc:\n        raise ValueError(f\"Failed to resolve analyzer '{analyzer_id}': {exc}\") from exc\n\n    if analyzer_info.base_analyzer_id:\n        return _BASE_TO_MODALITY.get(analyzer_info.base_analyzer_id, \"document\")\n    return \"document\"\n\n\ndef _is_analyzer_compatible(file_modality: str, analyzer_modality: str) -> bool:\n    \"\"\"Return True when an analyzer modality can process a file modality.\"\"\"\n    if analyzer_modality == \"document\":\n        return file_modality in {\"document\", \"image\"}\n    return file_modality == analyzer_modality\n\n\n# ---------------------------------------------------------------------------\n# Converter\n# ---------------------------------------------------------------------------\n\n","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/microsoft/markitdown/blob/fd239d5d2be43d9b68329730206b9312c7d5a388/packages/markitdown/src/markitdown/converters/_cu_converter.py#L404-L440","documentation":"ContentUnderstandingConverter resolves the modality of a custom (or unknown prebuilt) analyzer by calling client.get_analyzer(analyzer_id). Any exception from that Azure Content Understanding call — auth failure, 404 for a nonexistent analyzer, network/DNS error — is wrapped in ValueError with the analyzer id and the underlying message, chained via 'from exc'. Known prebuilt ids bypass the call entirely (cache hit).","triggerScenarios":"Constructing ContentUnderstandingConverter(analyzer_id='my-custom-analyzer') when the analyzer does not exist in the resource, the credential lacks permissions, the endpoint/credential is misconfigured, or the network is unreachable.","commonSituations":"Typos in analyzer_id, using an analyzer from a different Azure resource, expired service-principal secrets, or a correct id but environment variables (endpoint/keys) pointing at the wrong resource.","solutions":["Check the chained exception ('from exc') — a 404 means the id/resource is wrong; 401/403 means credentials","Verify the analyzer id and that it belongs to the endpoint's resource (list analyzers in the Azure portal or via the SDK)","Confirm credential setup: AZURE_API_KEY / DefaultAzureCredential login, and the correct CU endpoint","If network-bound, retry once connectivity is restored (the call happens once at converter init)"],"exampleFix":"# before\nconv = ContentUnderstandingConverter(analyzer_id=\"my-analyzer\")  # ValueError: Failed to resolve analyzer\n\n# after\nfrom azure.ai.contentsafety import ...  # verify via SDK/portal first:\n# client.list_analyzers() -> confirm id exists\nconv = ContentUnderstandingConverter(analyzer_id=\"my-analyzer-corrected\")","handlingStrategy":"try-catch","validationCode":"def analyzer_exists(client, analyzer_id: str) -> bool:\n    try:\n        client.get_analyzer(analyzer_id)\n        return True\n    except Exception:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    conv = ContentUnderstandingConverter(analyzer_id=analyzer_id, client=client)\nexcept ValueError as e:\n    if \"Failed to resolve analyzer\" in str(e):\n        log.error(\"analyzer %s unresolvable: %s\", analyzer_id, e.__cause__)\n        # fall back to default prebuilt analyzers (analyzer_id=None)\n        conv = ContentUnderstandingConverter(client=client)\n    else:\n        raise","preventionTips":["Validate analyzer ids against your Azure resource (portal or list API) at deploy time","Keep credential/endpoint env vars in deployment config, not code, and rotate before expiry","Default to prebuilt analyzers; treat custom ones as opt-in with a fallback path"],"tags":["azure","content-understanding","auth","analyzer"],"backgroundTag":null,"analyzedSha":"fd239d5d2be43d9b68329730206b9312c7d5a388","analyzedAt":"2026-08-14T15:47:51.745Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}