{"record":{"id":"fd86212c143ef010","repo":"BerriAI/litellm","slug":"bedrock-invokeguardrailchecks-returned-an-unexpect","errorCode":null,"errorMessage":"Bedrock InvokeGuardrailChecks returned an unexpected response shape","messagePattern":"Bedrock InvokeGuardrailChecks returned an unexpected response shape","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py","lineNumber":1824,"sourceCode":"                event_type=event_type,\n            )\n            raise HTTPException(status_code=status_code, detail=detail_message)\n\n        try:\n            json_response: Final = TypeAdapter(BedrockGuardrailChecksResponse).validate_python(httpx_response.json())\n        except (ValidationError, ValueError) as e:\n            verbose_proxy_logger.error(\"Bedrock InvokeGuardrailChecks: unparseable 200 response: %s\", str(e))\n            self.add_standard_logging_guardrail_information_to_request_data(\n                guardrail_provider=self.guardrail_provider,\n                guardrail_json_response={\"error\": str(e)},\n                request_data=request_data or {},  # mutable-ok: logging helper requires a dict\n                guardrail_status=\"guardrail_failed_to_respond\",\n                start_time=start_time.timestamp(),\n                end_time=datetime.now(timezone.utc).timestamp(),\n                duration=(datetime.now(timezone.utc) - start_time).total_seconds(),\n                event_type=event_type,\n            )\n            raise HTTPException(\n                status_code=500,\n                detail={\"error\": \"Bedrock InvokeGuardrailChecks returned an unexpected response shape\"},\n            ) from e\n        violations: Final = self._collect_invoke_checks_violations(json_response)\n\n        # Log a copy with PII location offsets stripped: offsets + the (separately\n        # logged) request messages would otherwise reconstruct the detected PII span.\n        self.add_standard_logging_guardrail_information_to_request_data(\n            guardrail_provider=self.guardrail_provider,\n            guardrail_json_response=self._sanitize_invoke_checks_response_for_logging(json_response),\n            request_data=request_data or {},  # mutable-ok: logging helper requires a dict\n            guardrail_status=self._get_invoke_checks_status(bool(violations)),\n            start_time=start_time.timestamp(),\n            end_time=datetime.now(timezone.utc).timestamp(),\n            duration=(datetime.now(timezone.utc) - start_time).total_seconds(),\n            event_type=event_type,\n            tracing_detail=self._build_invoke_checks_tracing_detail(violations) if violations else None,\n        )","sourceCodeStart":1806,"sourceCodeEnd":1842,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py#L1806-L1842","documentation":"Error \"Bedrock InvokeGuardrailChecks returned an unexpected response shape\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py:1824 when the library encounters an invalid state.","commonSituations":"Bedrock returned a response that did not match the expected schema.","solutions":["Check the raw Bedrock InvokeGuardrailChecks response in proxy logs.","Verify the Bedrock API version/region supports InvokeGuardrailChecks."],"exampleFix":"Enable debug logging and inspect the Bedrock response payload.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}