{"record":{"id":"7090bb30ac22824a","repo":"BerriAI/litellm","slug":"failed-to-parse-raw-azure-embedding-response-jso","errorCode":null,"errorMessage":"Failed to parse raw Azure embedding response: {json_error}","messagePattern":"Failed to parse raw Azure embedding response: (.+?)","errorType":"exception","errorClass":"AzureOpenAIError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure/azure.py","lineNumber":698,"sourceCode":"            raw_response: Final = await openai_aclient.embeddings.with_raw_response.create(**data, timeout=timeout)\n            headers: Final = dict(raw_response.headers)\n\n            # Convert json.JSONDecodeError to AzureOpenAIError for two critical reasons:\n            #\n            # 1. ROUTER BEHAVIOR: The router relies on exception.status_code to determine cooldown logic:\n            #    - JSONDecodeError has no status_code → router skips cooldown evaluation\n            #    - AzureOpenAIError has status_code → router properly evaluates for cooldown\n            #\n            # 2. CONNECTION CLEANUP: When response.parse() throws JSONDecodeError, the response\n            #    body may not be fully consumed, preventing httpx from properly returning the\n            #    connection to the pool. By catching the exception and accessing raw_response.status_code,\n            #    we trigger httpx's internal cleanup logic. Without this:\n            #    - parse() fails → JSONDecodeError bubbles up → httpx never knows response was acknowledged → connection leak\n            #    This completely eliminates \"Unclosed connection\" warnings during high load.\n            try:\n                response = raw_response.parse()\n            except json.JSONDecodeError as json_error:\n                raise AzureOpenAIError(\n                    status_code=raw_response.status_code or 500,\n                    message=f\"Failed to parse raw Azure embedding response: {json_error}\",\n                ) from json_error\n            if isinstance(response, str):\n                raise AzureOpenAIError(\n                    status_code=raw_response.status_code or 500,\n                    message=f\"Unexpected string response from Azure: {response[:500]}\",\n                )\n            stringified_response: Final = response.model_dump()\n\n            ## LOGGING\n            logging_obj.post_call(\n                input=input,\n                api_key=api_key,\n                additional_args={\"complete_input_dict\": data},\n                original_response=stringified_response,\n            )\n            embedding_response: Final = convert_to_model_response_object(","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/azure/azure.py#L680-L716","documentation":"Error \"Failed to parse raw Azure embedding response: {json_error}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/azure/azure.py:698 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the raw embedding response; it is not valid JSON. Verify the deployment and endpoint."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}