{"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/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/exception_mapping_utils.py#L2467-L2503","documentation":"Same unmapped-exception catch-all as the previous case, but for exceptions WITHOUT a 'request' attribute. LiteLLM embeds both the original exception and the full (redacted) Python traceback into the APIConnectionError message, and stubs a fake POST request to api.openai.com so the exception contract is satisfied. The traceback in the message is your primary debugging clue.","triggerScenarios":"Errors raised before/after any HTTP request object exists — e.g. errors during client construction, config parsing inside the call path, serialization bugs, or arbitrary exceptions thrown by provider adapters.","commonSituations":"Version mismatches between litellm and provider SDKs, provider adapter bugs on new API shapes, or non-HTTP exceptions (KeyError, TypeError) escaping adapter code.","solutions":["Read the traceback embedded in the message — the last frame names the actual failing code.","Align versions: upgrade litellm (pip install -U litellm) and its bundled openai dependency.","Report to litellm GitHub with the traceback if it points inside litellm/llms/... adapters.","As a stopgap, pin back to the last working litellm version."],"exampleFix":"# before\ntry:\n    litellm.completion(...)\nexcept Exception:\n    pass  # traceback lost\n\n# after\ntry:\n    litellm.completion(...)\nexcept litellm.APIConnectionError as e:\n    logger.error('litellm internal failure: %s', e.message)  # contains redacted traceback\n    raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await litellm.completion(...);\n} catch (e) {\n  if (e instanceof litellm.APIConnectionError) { /* e.message contains redacted traceback — log and report */ }\n}","preventionTips":["Pin known-good litellm/openai versions in requirements.","Keep the traceback from the message when filing issues.","Add integration smoke tests after dependency upgrades."],"tags":["unmapped-exception","traceback","sdk-version","bug-report"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}