Skip to content

Don't crash startup when litellm ships a new exception type - #5945

Open
inchang-ing wants to merge 1 commit into
Aider-AI:mainfrom
inchang-ing:fix/litellm-new-error-startup
Open

inchang-ing wants to merge 1 commit into
Aider-AI:mainfrom
inchang-ing:fix/litellm-new-error-startup

Conversation

@inchang-ing

Copy link
Copy Markdown

Closes #5944

Problem

litellm added new exception types (CallerCredentialAuthenticationError among them), and every aider invocation now dies at startup with:

ValueError: CallerCredentialAuthenticationError is in litellm but not in aider's exceptions list

LiteLLMExceptions._load already takes a strict parameter, but never reads it — the completeness check raises unconditionally, on the user-facing startup path (aider/coders/base_coder.py, aider/models.py), for every user, the moment litellm ships an exception that is not in aider's list.

Fix

  • Honor the existing strict parameter: strict=True keeps the loud ValueError as the development/CI drift check; the default lenient path now emits a UserWarning and moves on.
  • Deliberately not registering unknown errors into exceptions: dir(litellm) also surfaces re-exported third-party errors (with litellm 1.108.0 that includes pydantic's ValidationError and zoneinfo's ZoneInfoNotFoundError), and widening exceptions_tuple() would start catching those inside the send loops and mask unrelated bugs. Unmapped litellm errors keep flowing through the existing unmapped path in get_ex_info (ExInfo(None, None, None)).
  • Mapping the 8 currently-unmapped litellm errors (retry semantics per name) is a maintainer classification call, so I left the EXCEPTIONS list untouched — this PR is the mechanism fix.

Verification

  • Pre-fix with litellm 1.108.0, constructing LiteLLMExceptions() reproduces exactly the issue's failure: ValueError: CallerCredentialAuthenticationError is in litellm but not in aider's exceptions list.
  • Post-fix the same construction succeeds (warns once per unmapped name) and tests/basic/test_exceptions.py passes 9/9, including two new tests:
    • test_new_litellm_error_does_not_break_startup — a monkeypatched brand-new litellm error warns but does not crash construction and stays out of the catch tuple. Verified to fail on the unpatched code by stashing the fix and re-running.
    • test_strict_load_still_enforces_mapping — strict=True still raises ValueError for unmapped names.
  • black 23.3.0 --line-length 100 --preview, flake8 7.1.0 and isort 5.12.0 (the repo's pre-commit pins) are all clean on the two touched files.

Prepared with the assistance of an AI coding agent (an automated pipeline working on behalf of the account owner); the account owner submits and stands behind this PR.

LiteLLMExceptions._load has a strict parameter but never reads it: the
completeness check raised ValueError unconditionally on the user-facing
startup path, so any litellm release that adds a new exception type broke
aider for everyone (e.g. CallerCredentialAuthenticationError).

Honor the parameter: strict=True keeps the loud check, the default path
warns and moves on. Unmapped errors are deliberately not registered into
the catch tuple, because dir(litellm) also surfaces re-exported
third-party errors and widening the tuple would catch unrelated bugs.

Closes Aider-AI#5944
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

inchang-ing added a commit to inchang-ing/zcode-PR that referenced this pull request Nov 4, 2026
…down#1688 spelling fix staged

- Aider-AI/aider#5945: honor LiteLLMExceptions._load(strict); warn-only for
  unmapped litellm errors; pre-fail reproed on litellm 1.108.0, 9/9 tests,
  EVIDENCE_OK; awaiting account-holder CLA (web OAuth)
- inbox: 101 items dispositioned to 0 pending (gates 32 / same-repo cap 29 /
  collision yields 20 of 24 checked); dispositions 174 -> 273
- markdown#1688 pyspelling red triaged: .spell-dict +3 commit b878783 staged
  locally, push awaits owner (repo bans autonomous agent PR updates)

This branch has not been deployed

No deployments
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 ValueError in exceptions.py line 76

2 participants