BerriAI/litellm · error · ValueError
Failed to parse Bedrock batch response
Error message
Failed to parse Bedrock batch response: {e} What it means
Response-parsing failure in transform_create_batch_response: raw_response.json() raised while decoding the Bedrock CreateModelInvocationJob response, so the body is not valid JSON and cannot be validated into BedrockCreateBatchResponse.
Solutions
- Check the raw Bedrock batch response for unexpected fields or errors.
- Upgrade litellm if the response schema changed upstream.
- Retry the call; if persistent, capture the response and file an issue.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at litellm/llms/bedrock/batches/transformation.py:273 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/a45e1de319bdf1cd.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/bedrock/batches/transformation.py:273
"url": endpoint_url,
"headers": signed_headers,
"data": signed_data.decode("utf-8"),
}
def transform_create_batch_response(
self,
model: str | None,
raw_response: Response,
logging_obj: Any,
litellm_params: dict,
) -> LiteLLMBatch:
"""
Transform Bedrock batch creation response to LiteLLM format.
"""
try:
response_data: Final[BedrockCreateBatchResponse] = raw_response.json()
except Exception as e:
raise ValueError(f"Failed to parse Bedrock batch response: {e}")
# Extract information from typed Bedrock response
job_arn: Final = response_data.get("jobArn", "")
status_str: Final[str] = str(response_data.get("status", "Submitted"))
# Map Bedrock status to OpenAI-compatible status
status_mapping: Final[dict[str, str]] = {
"Submitted": "validating",
"Validating": "validating",
"Scheduled": "in_progress",
"InProgress": "in_progress",
"PartiallyCompleted": "completed",
"Completed": "completed",
"Failed": "failed",
"Stopping": "cancelling",
"Stopped": "cancelled",
"Expired": "expired",
}View on GitHub (pinned to 77b7c6c40c)