Skip to content

Fix: Updated error message for Gemini API#14589

Merged
2 commits merged into
BerriAI:mainfrom
timelfrink:fix/issue-14586-gemini-exception-messages
Sep 20, 2025
Merged

Fix: Updated error message for Gemini API#14589
2 commits merged into
BerriAI:mainfrom
timelfrink:fix/issue-14586-gemini-exception-messages

Conversation

@timelfrink

Copy link
Copy Markdown
Contributor

Summary

  • Fix Gemini API exception messages to show 'GeminiException' instead of 'VertexAIException'
  • Add comprehensive HTTP status code mapping for Gemini provider
  • Use LlmProviders enum constants for consistent provider identification

Issue Reference

Closes #14586

Changes Made

  1. Exception Mapping Fix: Updated exception mapping in litellm_core_utils/exception_mapping_utils.py to properly handle Gemini provider exceptions with correct naming
  2. Comprehensive Status Codes: Added missing HTTP status code mappings (401, 403, 404, 408, 429, 500+) for Gemini provider
  3. Enum Usage: Used LlmProviders enum constants instead of string literals for consistent provider identification
  4. Test Coverage: Added comprehensive test cases to verify Gemini exception mapping works correctly

Test Plan

  • Added unit tests for Gemini exception message format verification
  • Added parametrized tests for comprehensive HTTP status code handling
  • Tests verify 'GeminiException' appears in error messages instead of 'VertexAIException'
  • Tests cover all major HTTP status codes (400, 401, 403, 404, 408, 429, 500+)

- Update exception mapping to show 'GeminiException' instead of 'VertexAIException'
- Add comprehensive HTTP status code mapping for Gemini provider (401, 403, 404, 408, 429, 500+)
- Maintain OpenAI-compatible error handling patterns
- Use LlmProviders enum constants for consistent provider identification
- Add comprehensive test coverage for Gemini exception mapping
@vercel

vercel Bot commented Sep 15, 2025

Copy link
Copy Markdown

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

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Sep 18, 2025 1:54pm

model=model,
)
elif custom_llm_provider == "palm" or custom_llm_provider == "gemini":
elif custom_llm_provider == "palm" or custom_llm_provider == LlmProviders.GEMINI:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timelfrink we should not do this

  • both google ai studio (gemini/) and vertex ai (vertex_ai/) have the same set of error messages -

so we should use the same if/else block.

i agree on being more dynamic with the error string - to clarify the provider used

your pr can also clean up this code block - as it's a dead code block

@ghost ghost merged commit 0f0f432 into BerriAI:main Sep 20, 2025
5 of 6 checks passed
This pull request was closed.
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.

Updated error message for Gemini API

1 participant