{"record":{"id":"557b46981f62b818","repo":"BerriAI/litellm","slug":"original-exception-n-redact-string-traceback-fo","errorCode":null,"errorMessage":"{original_exception}\\n{_redact_string(traceback.format_exc())}","messagePattern":"\\{original_exception\\}\\\\n\\{_redact_string\\(traceback\\.format_exc\\(\\)\\)\\}","errorType":"exception","errorClass":"APIConnectionError","httpStatus":500,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":2485,"sourceCode":"                message=f\"{exception_provider} BadRequestError : This can happen due to missing AZURE_API_VERSION: {original_exception}\",\n                model=model,\n                llm_provider=custom_llm_provider,\n                response=getattr(original_exception, \"response\", None),\n            )\n        else:  # ensure generic errors always return APIConnectionError=\n            \"\"\"\n            For unmapped exceptions - raise the exception with traceback - https://github.com/BerriAI/litellm/issues/4201\n            \"\"\"\n            exception_mapping_worked = True\n            if hasattr(original_exception, \"request\"):\n                raise APIConnectionError(\n                    message=f\"{exception_provider} - {error_str}\",\n                    llm_provider=custom_llm_provider,\n                    model=model,\n                    request=getattr(original_exception, \"request\", None),\n                )\n            else:\n                raise APIConnectionError(\n                    message=f\"{original_exception}\\n{_redact_string(traceback.format_exc())}\",\n                    llm_provider=custom_llm_provider,\n                    model=model,\n                    request=httpx.Request(method=\"POST\", url=\"https://api.openai.com/v1/\"),  # stub the request\n                )\n    except Exception as e:\n        # LOGGING\n        exception_logging(\n            logger_fn=None,\n            additional_args={\n                \"exception_mapping_worked\": exception_mapping_worked,\n                \"original_exception\": original_exception,\n            },\n            exception=e,\n        )\n\n        # don't let an error with mapping interrupt the user from receiving an error from the llm api calls\n        if exception_mapping_worked:","sourceCodeStart":2467,"sourceCodeEnd":2503,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/exception_mapping_utils.py#L2467-L2503","documentation":"Companion branch for unmapped exceptions WITHOUT a request attribute: exception_type() raises APIConnectionError whose message embeds str(original_exception) plus a redacted traceback, and stubs the request as POST https://api.openai.com/v1/ (marked 'stub' in code). The traceback is included because for arbitrary exceptions it is the only way to diagnose the real cause (litellm#4201).","triggerScenarios":"Any exception escaping a provider call that litellm doesn't recognize and that lacks .request — e.g. KeyError/TypeError inside a provider adapter, parsing failures of response bodies, or non-HTTP library bugs. The redacted traceback in the message shows the true origin.","commonSituations":"litellm/provider SDK version mismatches producing TypeErrors; malformed streaming chunks breaking parsers; custom callback hooks raising; bugs in newly released provider integrations.","solutions":["Read the embedded traceback in the message — it pinpoints the file/line of the real failure, which is rarely a network issue despite the exception class.","Reproduce outside litellm with the provider SDK directly using the same parameters.","Upgrade or pin litellm and the provider SDK to a known-compatible pair.","Report to litellm with the traceback so the exception class gets a dedicated mapping."],"exampleFix":"# before\nlitellm.completion(model=\"<provider>/<model>\", messages=msgs)\n\n# after\ntry:\n    litellm.completion(model=\"<provider>/<model>\", messages=msgs)\nexcept litellm.APIConnectionError as e:\n    log.error(\"unmapped failure w/ traceback: %s\", e)  # traceback is inside the message\n    raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(**kwargs)\nexcept litellm.APIConnectionError as e:\n    if \"Traceback (most recent call last)\" in str(e):\n        # unmapped non-HTTP failure; traceback inside message is the real signal\n        capture_exception(e)  # ship to Sentry, etc.\n    raise","preventionTips":["Don't assume APIConnectionError means network — for unmapped errors the embedded traceback is the truth.","Ship these to error tracking; they usually indicate version bugs worth reporting.","Regression-test provider calls in CI after any litellm/SDK upgrade."],"tags":["unmapped-exception","traceback","connection-error","litellm","exception-mapping"],"backgroundTag":"api-connection-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}