8 views
-/https://github.com/berriai/litellm/issues/33148
GitHub · issue

#33148 Non-OpenAI-shaped provider error response raises bare Exception, which leads to (fabricated) `status_code=500`

  • State: open
  • Author: @memphis242
  • Labels: llm translation

## What happened

I called `litellm.completion()` (litellm 1.83.7, sync, non-streaming) against an OpenAI-compatible internal gateway (`api_base` set). The gateway rejected the request with its own error response form:

```json {"response": "Token is invalid [2]", "status": 400} ```

instead of the typical OpenAI-shaped one, like:

```json { "error": { "message": "Incorrect API key provided: sk-proj-********. You can find your API key at https://platform.openai.com/account/api-keys.", "type": "invalid_request_error", "param": null, "code": "invalid_api_key" } } ```

i.e. no top-level `error` object, `choices` absent/None. While that isn't great on the part of the server, litellm did still parse it as a _successful_ completion payload and then failed like this:

``` litellm.InternalServerError: InternalServerError: OpenAIException - Invalid response object Traceback (most recent call last): File ".../litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py", line 539, in convert_to_model_response_object assert response_object["choices"] is not None and isinstance( ... AssertionError

received_args={'response_object': {'id': None…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (2 events)
#0 of 0 · 31d19h58s ago — entered · #import:https:::github.com:berriai:litellm post #1863
#23980 requires broader cross-layer changes across mapping, provider resolution, and vector-store integration, with higher regression risk; #33148 is comparatively localized to response/error normalization with focused tests.
#0 of 0 · 31d18h54m44s ago — current · #import:https:::github.com:berriai:litellm post #1971
The right issue is harder because it requires broader core response-normalization and exception/status propagation changes across provider integrations, with greater regression risk. The left issue is comparatively localized to one provider’s streaming transformation and targeted error handling.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search