BoundaryML/baml · error
Expected message output to have content, but content is…
Error message
Expected message output to have content, but content is empty
What it means
chat_anyhow extracts text from the Converse message's content blocks; if the returned message has zero content blocks, there is nothing to extract and the client bails with this error. Bedrock normally always returns at least one content block in a message, so this indicates a degenerate/unexpected response.
Solutions
- Log/dump the raw response (StopReason, usage, output) to see why the model returned no content.
- Re-run the request; if reproducible, adjust the prompt or max_tokens so the model can produce output.
- Check guardrail/output filter configuration that might be suppressing all content blocks.
Defensive patterns
Strategy: try-catch
Try / catch
try:
out = baml_client.MyFunction(...)
except Exception as e:
if 'content is empty' in str(e):
log.warning('Bedrock returned empty message content; retrying')
out = retry_with_backoff(baml_client.MyFunction, ...)
else:
raise Prevention
- Set adequate max_tokens so the model can produce content
- Test prompts against real Bedrock endpoints, not just mocks
- Capture StopReason with each call to diagnose empty outputs
When it happens
Trigger: Bedrock Converse returns ConverseOutput::Message whose content array is empty — e.g. the model returned an empty response, output filtering removed all blocks, or a malformed response from a proxy/mocked endpoint.
Common situations: Using mock/proxy Bedrock endpoints in tests that return empty messages; guardrail or output filtering stripping all content; hitting a model that returns empty content on certain prompts.
Understand the failure class
Background: "empty response", "returned no data", "empty embeddings": what HTTP 200-with-empty-body errors mean across libraries — this error's family across 36 libraries.
Related errors
- Expected message output in response, but is type
- Expected message output to contain at least one text block…
- AWS Bedrock modular streaming is not supported. Use…
- AWS Bedrock only supports text system blocks, but got
- AWS Bedrock requires s3:// URIs, but got
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/b77177b8297e44ba.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:696
bedrock_config = bedrock_config.endpoint_url(endpoint_url);
}
Ok(BedrockRuntimeClient::from_conf(bedrock_config.build()))
}
async fn chat_anyhow(&self, response: &ConverseOutput) -> Result<String> {
let Some(bedrock::types::ConverseOutput::Message(ref message)) = response.output else {
anyhow::bail!(
"Expected message output in response, but is type {}",
"unknown"
);
};
// Try to extract text from all content blocks
let mut extracted_text = String::new();
let mut has_text = false;
if message.content.is_empty() {
anyhow::bail!("Expected message output to have content, but content is empty");
}
for content_block in &message.content {
if let bedrock::types::ContentBlock::Text(text) = content_block {
has_text = true;
extracted_text.push_str(text);
}
}
// If we found at least one text block, return the concatenated text
if has_text {
let content = extracted_text;
return Ok(content);
}
// If we didn't find any text blocks, return an error with details about the content
anyhow::bail!(
"Expected message output to contain at least one text block, but found none. Content: {:?}",View on GitHub (pinned to bd85ce9dee)