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

#35544 [Bug]: RejectedRequestError message prefixes leak into completion content

  • State: open
  • Author: @johnpwhite

## What happened?

`RejectedRequestError` is the proxy's mechanism for returning a message to the caller instead of calling the model — `proxy_server.py` catches it and builds a response:

```python except RejectedRequestError as e: _chat_response = litellm.ModelResponse() _chat_response.choices[0].message.content = e.message # <- user-facing content ... return _chat_response ```

But `e.message` has been prefixed **twice** by the time it lands there, so the caller receives the exception class names inside the completion text.

### Cause

`litellm/exceptions.py`:

```python class RejectedRequestError(BadRequestError): def __init__(self, message, model, llm_provider, request_data, litellm_debug_info=None): self.status_code = 400 self.message = "litellm.RejectedRequestError: {}".format(message) # prefix #1 ... super().__init__(message=self.message, ...) # prefix #2 in BadRequestError ```

Supplying `"366"` therefore delivers:

```json {"choices":[{"message":{"content":"litellm.BadRequestError: litellm.RejectedRequestError: 366"}}]} ```

HTTP 200, correct latency, correct routing — only the text is wro…

GitHub resolver

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

Refresh page
vote history (2 events)
#0 of 0 · 31d18h46m37s ago — entered · #import:https:::github.com:berriai:litellm post #2189
The right-hand issue is harder because it spans caching, TTL handling, Redis integration, circuit-breaker behavior, and upgrade compatibility across deployments. The left-hand issue appears localized to exception construction and response formatting, with comparatively narrow code and test changes.
#0 of 0 · 31d17h51m45s ago — current · #import:https:::github.com:berriai:litellm post #3107
The left requires provider-specific request translation changes, compatibility validation, and coverage across affected model paths, while the right is primarily a localized exception-formatting correction with focused regression tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search