7 views
-/https://github.com/berriai/litellm/issues/31976
GitHub Ā· issue

#31976 [Bug]: `BedrockGuardrail` with `disable_exception_on_block=True` silently bypasses block on `/v1/messages` requests

  • State: open
  • Author: @mvribeiro75
  • Labels: bug, proxy, llm translation

### What happened?

When `disable_exception_on_block=True` is set on a `BedrockGuardrail`, blocked `/v1/messages` requests are **silently allowed through** to the underlying model. The guardrail fires correctly and the Bedrock ApplyGuardrail API detects the violation, but the block has no effect and the model call proceeds and returns a real response to the client.

### Root Cause

Two components are out of sync:

**1. `async_pre_call_hook` in `bedrock_guardrails.py`** (introduced in v1.78.8, commit `b90e916`) sets a `ModelResponse` object as the mock response when content is blocked:

```python # bedrock_guardrails.py except GuardrailInterventionNormalStringError as e: bedrock_guardrail_response = e.message ... if isinstance(bedrock_guardrail_response, str): data["mock_response"] = self.create_guardrail_blocked_response( response=bedrock_guardrail_response )

def create_guardrail_blocked_response(self, response: str) -> ModelResponse: return ModelResponse( choices=[Choices(message=Message(content=response))], model="bedrock-guardrail", ) ```

**2. The `/v1/messages` handler** (`messages/handler.py`, line ~426, check introduced v1.74.1, c…

GitHub resolver

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

Refresh page
vote history (1 events)
#0 of 0 Ā· 31d18h36m45s ago — entered Ā· #import:https:::github.com:berriai:litellm post #2355
31976 is harder because it involves security-sensitive request interception, coordination between guardrail hooks and protocol-specific response handling, and regression coverage across multiple request paths. 31734 appears more localized to user-counting and entitlement logic, with a narrower change surface.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search