Skip to content

fix: handle missing litellm exception classes gracefully#4960

Open
scinttt wants to merge 1 commit intoAider-AI:mainfrom
scinttt:fix/uncaught-attributeerror-litellm-4957
Open

fix: handle missing litellm exception classes gracefully#4960
scinttt wants to merge 1 commit intoAider-AI:mainfrom
scinttt:fix/uncaught-attributeerror-litellm-4957

Conversation

@scinttt
Copy link
Copy Markdown

@scinttt scinttt commented Mar 26, 2026

Problem

When a litellm version removes or renames an exception class, LiteLLMExceptions._load() crashes with an uncaught AttributeError because getattr(litellm, var) is called without a default value.

Root Cause

In aider/exceptions.py line 78, the code iterates over self.exception_info and calls getattr(litellm, var) — if the attribute doesn't exist (e.g., litellm dropped or renamed it), this raises AttributeError.

Fix

Use getattr(litellm, var, None) with a continue to gracefully skip missing exception classes instead of crashing. This is a 2-line change.

Tests

  • Added test_missing_litellm_exception_does_not_crash regression test that temporarily removes litellm.APIConnectionError and verifies LiteLLMExceptions() still loads without error

Fixes #4957

When a litellm version removes or renames an exception class,
`LiteLLMExceptions._load()` raised an uncaught `AttributeError`
because `getattr(litellm, var)` was called without a default.

Use `getattr(litellm, var, None)` with a `continue` to skip
missing classes instead of crashing.

Fixes Aider-AI#4957
@scinttt scinttt force-pushed the fix/uncaught-attributeerror-litellm-4957 branch from 2cd26fb to a0862ac Compare March 26, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uncaught AttributeError in exceptions.py line 74

1 participant