BoundaryML/baml · error
AWS Bedrock only supports text blocks for system messages…
Error message
AWS Bedrock only supports text blocks for system messages, but got {:#?} What it means
Bedrock system prompts may only contain SystemContentBlock::Text. When a system-role message part is a media (ChatMessagePart::Media), BAML cannot convert it and bails. System messages in Bedrock have no way to carry image/pdf/video blocks, so media there is always invalid.
Solutions
- Move the media out of the system message into a user/assistant message.
- Replace the system media with a text description of the content.
- If it was accidental, fix the prompt template role so media lives under user role.
- Use a provider that supports media in system messages if that design is required.
Example fix
// before
message "system" { {#.image} } // media in system
// after
message "system" "You are a vision assistant."
message "user" { {#.image} } Defensive patterns
Strategy: validation
Validate before calling
if (systemMessageParts.some(p => p.type !== 'text')) { throw new Error('AWS Bedrock system messages must be text-only; move media to a user message.'); } Type guard
const systemIsTextOnly = (parts) => parts.every(p => p.type === 'text');
Try / catch
try { await b.MyPrompt(...) } catch (e) { if (String(e).includes('only supports text blocks for system messages')) { /* relocate media parts to user role and retry */ } else throw e; } Prevention
- Keep system prompts text-only for Bedrock clients.
- Place images/PDFs/videos in user-role messages.
- Audit prompt templates ported from other providers for media in system role.
When it happens
Trigger: Putting media content (image/pdf/video) inside a system-role message of a prompt run against an AWS Bedrock client, including media nested inside WithMeta parts without cache_control-only metadata.
Common situations: Copying a chat-template that includes an image in the system prompt (common with OpenAI) and running it on Bedrock; multimodal system instructions that another provider tolerated.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- AWS Bedrock does not support audio media type
- BAML internal error (AWSBedrock): file should have been…
- BAML internal error (AWSBedrock): Pdf file should have been…
- BAML internal error (AWSBedrock): video file should have…
- Audio is not a URL
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/3e2c73a462b044b7.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:1294
.flatten()
.collect();
bedrock::types::Message::builder()
.set_role(Some(msg.role.as_str().into()))
.set_content(Some(content))
.build()
.map_err(|e: bedrock::error::BuildError| e.into())
}
fn part_to_system_message(
part: &ChatMessagePart,
allowed_metadata: &AllowedRoleMetadata,
) -> Result<Vec<bedrock::types::SystemContentBlock>> {
match part {
ChatMessagePart::Text(t) => {
Ok(vec![bedrock::types::SystemContentBlock::Text(t.clone())])
}
ChatMessagePart::Media(_) => anyhow::bail!(
"AWS Bedrock only supports text blocks for system messages, but got {:#?}",
part
),
ChatMessagePart::WithMeta(p, meta) => {
let mut blocks = Self::part_to_system_message(p, allowed_metadata)?;
if allowed_metadata.is_allowed("cache_control")
&& meta.contains_key("cache_control")
{
blocks.push(bedrock::types::SystemContentBlock::CachePoint(
bedrock::types::CachePointBlock::builder()
.r#type(bedrock::types::CachePointType::Default)
.build()?,
));
}
Ok(blocks)
}
}
}View on GitHub (pinned to bd85ce9dee)