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
This commit is contained in:
Yucheng Zhu 2026-08-06 14:05:46 -07:00
parent a6ad663af1
commit a08e4cf309

View file

@ -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"