fix: handle missing litellm exception classes gracefully#4960
Open
scinttt wants to merge 1 commit intoAider-AI:mainfrom
Open
fix: handle missing litellm exception classes gracefully#4960scinttt wants to merge 1 commit intoAider-AI:mainfrom
scinttt wants to merge 1 commit intoAider-AI:mainfrom
Conversation
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
2cd26fb to
a0862ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a litellm version removes or renames an exception class,
LiteLLMExceptions._load()crashes with an uncaughtAttributeErrorbecausegetattr(litellm, var)is called without a default value.Root Cause
In
aider/exceptions.pyline 78, the code iterates overself.exception_infoand callsgetattr(litellm, var)— if the attribute doesn't exist (e.g., litellm dropped or renamed it), this raisesAttributeError.Fix
Use
getattr(litellm, var, None)with acontinueto gracefully skip missing exception classes instead of crashing. This is a 2-line change.Tests
test_missing_litellm_exception_does_not_crashregression test that temporarily removeslitellm.APIConnectionErrorand verifiesLiteLLMExceptions()still loads without errorFixes #4957