BerriAI/litellm · error · HTTPException
Bedrock InvokeGuardrailChecks returned an unexpected respons
Error message
Bedrock InvokeGuardrailChecks returned an unexpected response shape
What it means
Error "Bedrock InvokeGuardrailChecks returned an unexpected response shape" thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py:1824
event_type=event_type,
)
raise HTTPException(status_code=status_code, detail=detail_message)
try:
json_response: Final = TypeAdapter(BedrockGuardrailChecksResponse).validate_python(httpx_response.json())
except (ValidationError, ValueError) as e:
verbose_proxy_logger.error("Bedrock InvokeGuardrailChecks: unparseable 200 response: %s", str(e))
self.add_standard_logging_guardrail_information_to_request_data(
guardrail_provider=self.guardrail_provider,
guardrail_json_response={"error": str(e)},
request_data=request_data or {}, # mutable-ok: logging helper requires a dict
guardrail_status="guardrail_failed_to_respond",
start_time=start_time.timestamp(),
end_time=datetime.now(timezone.utc).timestamp(),
duration=(datetime.now(timezone.utc) - start_time).total_seconds(),
event_type=event_type,
)
raise HTTPException(
status_code=500,
detail={"error": "Bedrock InvokeGuardrailChecks returned an unexpected response shape"},
) from e
violations: Final = self._collect_invoke_checks_violations(json_response)
# Log a copy with PII location offsets stripped: offsets + the (separately
# logged) request messages would otherwise reconstruct the detected PII span.
self.add_standard_logging_guardrail_information_to_request_data(
guardrail_provider=self.guardrail_provider,
guardrail_json_response=self._sanitize_invoke_checks_response_for_logging(json_response),
request_data=request_data or {}, # mutable-ok: logging helper requires a dict
guardrail_status=self._get_invoke_checks_status(bool(violations)),
start_time=start_time.timestamp(),
end_time=datetime.now(timezone.utc).timestamp(),
duration=(datetime.now(timezone.utc) - start_time).total_seconds(),
event_type=event_type,
tracing_detail=self._build_invoke_checks_tracing_detail(violations) if violations else None,
)View on GitHub (pinned to 77b7c6c40c)
Solutions
- Check the raw Bedrock InvokeGuardrailChecks response in proxy logs.
- Verify the Bedrock API version/region supports InvokeGuardrailChecks.
Example fix
Enable debug logging and inspect the Bedrock response payload.
When it happens
Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py:1824 when the library encounters an invalid state.
Common situations: Bedrock returned a response that did not match the expected schema.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/fd86212c143ef010.
Report an issue: GitHub.