BerriAI/litellm · error · ValueError
Invalid batch_id format. Expected ARN, got
Error message
Invalid batch_id format. Expected ARN, got: {batch_id} What it means
Format guard in batch retrieval transformation: the supplied batch_id does not start with 'arn:aws:bedrock:', but the GetModelInvocationJob API requires the full job ARN as the identifier. The caller passed an OpenAI-style batch id instead.
Solutions
- Pass the full batch job ARN as batch_id (arn:aws:bedrock:...).
- Use the ARN returned at batch creation time, not a short id.
- Check for truncation or typos in batch_id.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/llms/bedrock/batches/transformation.py:375 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/fe2ab1586964d64b.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/bedrock/batches/transformation.py:375
batch_id: str,
optional_params: dict,
litellm_params: dict,
) -> dict[str, Any]:
"""
Transform batch retrieval request for Bedrock.
Args:
batch_id: Bedrock job ARN
optional_params: Optional parameters
litellm_params: LiteLLM parameters
Returns:
Transformed request data for Bedrock GetModelInvocationJob API
"""
# For Bedrock, batch_id should be the full job ARN
# The GetModelInvocationJob API expects the full ARN as the identifier
if not batch_id.startswith("arn:aws:bedrock:"):
raise ValueError(f"Invalid batch_id format. Expected ARN, got: {batch_id}")
# Extract the job identifier from the ARN - use the full ARN path part
# ARN format: arn:aws:bedrock:region:account:model-invocation-job/job-name
arn_parts: Final = batch_id.split(":")
if len(arn_parts) < 6:
raise ValueError(f"Invalid ARN format: {batch_id}")
region: Final = arn_parts[3]
if not re.match(r"^[a-z][a-z0-9-]*$", region):
raise ValueError(f"Invalid region in ARN: {batch_id}")
# Build the endpoint URL for GetModelInvocationJob
# AWS API format: GET /model-invocation-job/{jobIdentifier}
# Use the FULL ARN as jobIdentifier and URL-encode it (includes ':' and '/')
import urllib.parse as _ul
encoded_arn: Final = _ul.quote(batch_id, safe="")
endpoint_url: Final = f"https://bedrock.{region}.amazonaws.com/model-invocation-job/{encoded_arn}"View on GitHub (pinned to 77b7c6c40c)