{"record":{"id":"278719aba3bc0ab2","repo":"BerriAI/litellm","slug":"most-recent-exception-str-all-fallback-attempts","errorCode":null,"errorMessage":"{most_recent_exception_str}. All fallback attempts failed. Enable verbose logging with `litellm.set_verbose=True` for details.","messagePattern":"(.+?)\\. All fallback attempts failed\\. Enable verbose logging with `litellm\\.set_verbose=True` for details\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"litellm/litellm_core_utils/fallback_utils.py","lineNumber":79,"sourceCode":"\n            response = await litellm.acompletion(\n                **completion_kwargs,\n                model=model,\n                litellm_logging_obj=litellm_logging_obj,\n            )\n\n            if response is not None:\n                return add_fallback_headers_to_response(\n                    response=response,\n                    attempted_fallbacks=attempted_fallbacks,\n                )\n\n        except Exception as e:\n            verbose_logger.exception(\"Fallback attempt failed for model %s: %s\", model, e)\n            most_recent_exception_str = str(e)\n            continue\n\n    raise Exception(\n        f\"{most_recent_exception_str}. All fallback attempts failed. Enable verbose logging with `litellm.set_verbose=True` for details.\"\n    )\n\n\ndef completion_with_fallbacks(**kwargs):\n    return run_async_function(async_function=async_completion_with_fallbacks, **kwargs)\n","sourceCodeStart":61,"sourceCodeEnd":86,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/fallback_utils.py#L61-L86","documentation":"In fallback_utils, the fallback loop tries each configured fallback model; every attempt's exception is caught, its string saved as most_recent_exception_str, and the loop continues. If ALL attempts fail, litellm raises a plain Exception: '<last error>. All fallback attempts failed. Enable verbose logging with `litellm.set_verbose=True` for details.' Note it is a builtin Exception, not a litellm error subclass, and only the LAST error's string survives.","triggerScenarios":"Every model in a fallback chain failing: primary + all fallbacks have bad credentials (401), are rate-limited (429), unreachable (DNS/proxy), or their model slugs are invalid (404). The message shows only the final fallback's error; earlier ones appear only in verbose logs.","commonSituations":"Shared bad API key across all fallback deployments; exhausting rate limits on every provider simultaneously during traffic spikes; fallback lists pointing at deleted/renamed models; network egress blocked to all provider domains; router configs copying the same wrong env var into every entry.","solutions":["Enable litellm.set_verbose = True and rerun to see each individual fallback failure in logs.","Fix the error shown in the message first — it's the last fallback's cause and usually the same for all (auth, rate limit, connectivity).","Diversify fallbacks across providers/keys/regions so one failure mode can't take down the whole chain.","Catch the raised Exception explicitly (it's not a litellm.Timeout/APIError subclass) and alert on it — total fallback exhaustion is an operational event."],"exampleFix":"# before\nresponse = completion_with_fallbacks(model=gpt4, fallbacks=[\"gpt-3.5-turbo\"], **kwargs)\n\n# after\nimport litellm\nlitellm.set_verbose = True  # log per-fallback failures\ntry:\n    response = completion_with_fallbacks(model=gpt4, fallbacks=[\"claude-3-5-sonnet\", \"gpt-4o-mini\"], **kwargs)\nexcept Exception as e:  # plain Exception, not a litellm subclass\n    alert(\"all fallbacks exhausted\", last_error=str(e))\n    raise","handlingStrategy":"fallback","validationCode":"# before running the chain: sanity-check every model in it\nimport litellm\nfor m in [primary, *fallbacks]:\n    assert isinstance(m, str) and m, f\"bad model entry: {m!r}\"\n    assert provider_creds_present(m), f\"no credentials configured for {m}\"","typeGuard":null,"tryCatchPattern":"try:\n    response = completion_with_fallbacks(model=primary, fallbacks=fbs, **kwargs)\nexcept Exception as e:  # NOTE: plain Exception, not a litellm error subclass\n    if \"All fallback attempts failed\" in str(e):\n        page_oncall(\"entire fallback chain down\", last_error=str(e))\n    raise","preventionTips":["Run litellm.set_verbose = True in lower environments so per-fallback failures are visible.","Diversify fallbacks across providers AND credentials so one failure mode can't kill the chain.","Catch builtin Exception for this path — litellm-specific except clauses will miss it.","Alert on fallback exhaustion as a critical event; the message only carries the last error."],"tags":["fallback","all-providers-failed","router","litellm","resilience"],"backgroundTag":"fallback-exhausted","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}