{"record":{"id":"9a52c5ee23a36bea","repo":"BerriAI/litellm","slug":"badgatewayerror-exception-provider-message","errorCode":null,"errorMessage":"BadGatewayError: {exception_provider} - {message}","messagePattern":"BadGatewayError: (.+?) - (.+?)","errorType":"exception","errorClass":"BadGatewayError","httpStatus":502,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":457,"sourceCode":"            )\n        elif original_exception.status_code == 429:\n            raise RateLimitError(\n                message=f\"RateLimitError: {exception_provider} - {message}\",\n                model=model,\n                llm_provider=custom_llm_provider,\n                response=getattr(original_exception, \"response\", None),\n                litellm_debug_info=extra_information,\n            )\n        elif original_exception.status_code == 500:\n            raise InternalServerError(\n                message=f\"InternalServerError: {exception_provider} - {message}\",\n                model=model,\n                llm_provider=custom_llm_provider,\n                response=getattr(original_exception, \"response\", None),\n                litellm_debug_info=extra_information,\n            )\n        elif original_exception.status_code == 502:\n            raise BadGatewayError(\n                message=f\"BadGatewayError: {exception_provider} - {message}\",\n                model=model,\n                llm_provider=custom_llm_provider,\n                response=getattr(original_exception, \"response\", None),\n                litellm_debug_info=extra_information,\n            )\n        elif original_exception.status_code == 503:\n            raise ServiceUnavailableError(\n                message=f\"ServiceUnavailableError: {exception_provider} - {message}\",\n                model=model,\n                llm_provider=custom_llm_provider,\n                response=getattr(original_exception, \"response\", None),\n                litellm_debug_info=extra_information,\n            )\n        elif original_exception.status_code == 504:  # gateway timeout error\n            raise Timeout(\n                message=f\"Timeout Error: {exception_provider} - {message}\",\n                model=model,","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/exception_mapping_utils.py#L439-L475","documentation":"Generic provider status-code mapping: an upstream exception with HTTP 502 is re-raised as LiteLLM's BadGatewayError, signaling an upstream proxy/gateway failure rather than a LiteLLM fault.","triggerScenarios":"Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:457 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Bad gateway from the provider/upstream; retry after a short delay.","Check provider status and any intermediary proxies/gateways."],"exampleFix":null,"handlingStrategy":"retry","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"}