Skip to content

Conversation

@yurekami
Copy link

Summary

  • Fix spurious APIError when OpenAI-compatible providers return empty error objects on successful responses
  • Some providers (e.g., Apertis with minimax models) return error objects like {"message": "", "type": "", "param": "", "code": null} even on success
  • The previous check only verified error is not None, which incorrectly triggered exceptions for empty error dicts

Changes

The error detection now checks if the error object contains meaningful data:

  • For dict errors: non-empty message OR non-null code
  • For string errors: non-empty string
  • Other truthy values are still treated as errors

Fixes #18407

Test plan

  • Added test for empty error object with all null/empty fields (should NOT raise)
  • Added test for real error with message (should raise)
  • Added test for completely empty error dict {} (should NOT raise)
  • Added test for error with only code, no message (should raise)

🤖 Generated with Claude Code

Some OpenAI-compatible providers (e.g., Apertis) return empty error
objects even on successful responses. The previous check only verified
that error was not None, causing spurious APIErrors.

Now the code checks if the error object contains meaningful data:
- For dict errors: non-empty message OR non-null code
- For string errors: non-empty string
- Other truthy values are still treated as errors

Fixes BerriAI#18407

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@vercel
Copy link

vercel bot commented Dec 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
litellm Ready Ready Preview, Comment Dec 28, 2025 10:39pm

@CLAassistant
Copy link

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.

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.

[Bug]: APIError raised for OpenAI-compatible responses containing empty error objects (e.g. Apertis)

2 participants