{"record":{"id":"ab335e03fe262e0a","repo":"BoundaryML/baml","slug":"aws-bedrock-only-supports-text-system-blocks-but-got-other","errorCode":null,"errorMessage":"AWS Bedrock only supports text system blocks, but got {other:?}","messagePattern":"AWS Bedrock only supports text system blocks, but got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs","lineNumber":136,"sourceCode":"\nfn cache_point_json() -> serde_json::Value {\n    json!({\"cachePoint\": {\"type\": \"default\"}})\n}\n\nfn system_part_to_json(\n    part: &ChatMessagePart,\n    allowed_metadata: &AllowedRoleMetadata,\n) -> Result<Vec<serde_json::Value>> {\n    match part {\n        ChatMessagePart::Text(t) => Ok(vec![json!({ \"text\": t })]),\n        ChatMessagePart::WithMeta(p, meta) => {\n            let mut blocks = system_part_to_json(p, allowed_metadata)?;\n            if allowed_metadata.is_allowed(\"cache_control\") && meta.contains_key(\"cache_control\") {\n                blocks.push(cache_point_json());\n            }\n            Ok(blocks)\n        }\n        other => anyhow::bail!(\"AWS Bedrock only supports text system blocks, but got {other:?}\"),\n    }\n}\n\nfn chat_part_to_json(\n    part: &ChatMessagePart,\n    allowed_metadata: &AllowedRoleMetadata,\n) -> Result<Vec<serde_json::Value>> {\n    match part {\n        ChatMessagePart::Text(t) => Ok(vec![json!({ \"text\": t })]),\n        ChatMessagePart::Media(media) => Ok(vec![media_to_content_block_json(media)?]),\n        ChatMessagePart::WithMeta(inner, meta) => {\n            let mut blocks = chat_part_to_json(inner, allowed_metadata)?;\n            if allowed_metadata.is_allowed(\"cache_control\") && meta.contains_key(\"cache_control\") {\n                blocks.push(cache_point_json());\n            }\n            Ok(blocks)\n        }\n    }","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs#L118-L154","documentation":"system_part_to_json only knows how to render system prompt parts that are plain text (or text wrapped in metadata for cache_control). If a system message part is some other variant (e.g. media, image, or tool content in the system role), the client bails because the Bedrock Converse 'system' field accepts only text blocks (plus cachePoint).","triggerScenarios":"Rendering a chat where the system role message contains a non-text part — e.g. an image/media part placed in the system prompt, or tool-call content in the system role — when building the Converse request body for aws-bedrock.","commonSituations":"Migrating prompts written for providers that tolerate images in the system prompt (some Anthropic setups) to Bedrock; accidentally passing a media block into the system message via templating; putting tool definitions/results in the system role.","solutions":["Move any media or non-text content out of the system role into a user/assistant message, keeping the system prompt text-only.","Ensure tool definitions are passed via the provider's tool parameter mechanism, not embedded in system message parts.","If you need prompt caching, attach cache_control metadata to the text system part (it is converted to a cachePoint block) rather than changing the part type."],"exampleFix":"// before\nmessage System { {{ctx_image}} You are helpful. }\n// after\nmessage System { You are helpful. }\nmessage User { {{ctx_image}} Describe this. }","handlingStrategy":"validation","validationCode":"for part in system_message['parts']:\n    if part['type'] != 'text':\n        raise ValueError(f\"aws-bedrock system prompt must be text-only, got {part['type']}\")","typeGuard":"def is_text_system_message(msg) -> bool:\n    return all(p.get('type') == 'text' for p in msg.get('parts', []))","tryCatchPattern":null,"preventionTips":["Keep system prompts text-only; put media in user messages","Never embed tool definitions or results in the system role","Review prompt templates when porting from other providers to aws-bedrock"],"tags":["aws","bedrock","system-prompt","validation","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}