From a08e4cf309fde77416d42615f91c4941faa98298 Mon Sep 17 00:00:00 2001 From: Yucheng Zhu Date: Thu, 6 Aug 2026 14:05:46 -0700 Subject: [PATCH] fix(guardrails): raise 500 when Bedrock reports a failure inside a 200 body Also types the credentials parameter on the new chunking helpers and rebuilds fragment grouping without mutating a list or rebinding an index --- .../guardrails/guardrail_hooks/test_bedrock_guardrails.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py index 819a6dc20c8..0b72633e4a2 100644 --- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py +++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py @@ -4616,12 +4616,13 @@ async def test_apply_guardrail_exception_inside_200_logs_failure_not_success(): ): mock_post.return_value = exception_response - with pytest.raises(HTTPException): + with pytest.raises(HTTPException) as raised: await guardrail.make_bedrock_api_request( source="INPUT", messages=[{"role": "user", "content": "hello"}], request_data={"model": "bedrock-nova-micro"}, ) + assert raised.value.status_code == 500 mock_log.assert_called_once() assert mock_log.call_args.kwargs["guardrail_status"] == "guardrail_failed_to_respond"