6 views
-/https://github.com/berriai/litellm/issues/29436
GitHub · issue

#29436 CustomCodeExecutionError from guardrail block surfaces as HTTP 500 instead of 400

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

## Description

When a `custom_code` guardrail (e.g. LLM Guard) detects a policy violation and blocks the request, the resulting `CustomCodeExecutionError` is not translated into a proper HTTP error response — it surfaces as **500 Internal Server Error** instead of **400 Bad Request** or **403 Forbidden**.

The guardrail is working correctly (the block is enforced), but the status code is wrong.

## Stack trace (from proxy logs)

``` File ".../litellm/llms/openai/chat/guardrail_translation/handler.py", line 111, in process_input_messages guardrailed_inputs = await guardrail_to_apply.apply_guardrail(...) File ".../litellm/integrations/custom_guardrail.py", line 949, in async_wrapper return self._process_error(e=e, ...)

CustomCodeExecutionError: Custom code guardrail execution failed: Content policy violation: PromptInjection

INFO: 127.0.0.1:43604 - "POST /v1/chat/completions HTTP/1.1" 500 Internal Server Error ```

## Expected behavior

A guardrail block should return **400** (or **403**), not **500**. The 5xx range implies a server fault; a content policy rejection is a client-side condition.

## Impact

- Callers cannot distinguish a guardrail block from a genuine proxy …

GitHub resolver

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

Refresh page
vote history (1 events)
#0 of 0 · 31d18h35m54s ago — entered · #import:https:::github.com:berriai:litellm post #2565
29436 requires tracing exception propagation across guardrail, translation, and HTTP response layers, defining compatible status semantics, and adding regression coverage; 32778 is comparatively localized logging-policy cleanup with limited behavioral risk.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search