{"record":{"id":"b77177b8297e44ba","repo":"BoundaryML/baml","slug":"expected-message-output-to-have-content-but-content-is-empty","errorCode":null,"errorMessage":"Expected message output to have content, but content is empty","messagePattern":"Expected message output to have content, but content is empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs","lineNumber":696,"sourceCode":"            bedrock_config = bedrock_config.endpoint_url(endpoint_url);\n        }\n\n        Ok(BedrockRuntimeClient::from_conf(bedrock_config.build()))\n    }\n\n    async fn chat_anyhow(&self, response: &ConverseOutput) -> Result<String> {\n        let Some(bedrock::types::ConverseOutput::Message(ref message)) = response.output else {\n            anyhow::bail!(\n                \"Expected message output in response, but is type {}\",\n                \"unknown\"\n            );\n        };\n        // Try to extract text from all content blocks\n        let mut extracted_text = String::new();\n        let mut has_text = false;\n\n        if message.content.is_empty() {\n            anyhow::bail!(\"Expected message output to have content, but content is empty\");\n        }\n\n        for content_block in &message.content {\n            if let bedrock::types::ContentBlock::Text(text) = content_block {\n                has_text = true;\n                extracted_text.push_str(text);\n            }\n        }\n\n        // If we found at least one text block, return the concatenated text\n        if has_text {\n            let content = extracted_text;\n            return Ok(content);\n        }\n\n        // If we didn't find any text blocks, return an error with details about the content\n        anyhow::bail!(\n            \"Expected message output to contain at least one text block, but found none. Content: {:?}\",","sourceCodeStart":678,"sourceCodeEnd":714,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs#L678-L714","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    out = baml_client.MyFunction(...)\nexcept Exception as e:\n    if 'content is empty' in str(e):\n        log.warning('Bedrock returned empty message content; retrying')\n        out = retry_with_backoff(baml_client.MyFunction, ...)\n    else:\n        raise","preventionTips":["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"],"tags":["aws","bedrock","empty-response","response"],"backgroundTag":"empty-api-response","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}