{"record":{"id":"c5c3a81257d9de00","repo":"BoundaryML/baml","slug":"aws-bedrock-requires-s3-uris-but-got","errorCode":null,"errorMessage":"AWS Bedrock requires s3:// URIs, but got: {}","messagePattern":"AWS Bedrock requires s3:// URIs, but got: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs","lineNumber":89,"sourceCode":"fn strip_mime_prefix(mime: &str) -> &str {\n    mime.split_once('/').map(|(_, s)| s).unwrap_or(mime)\n}\n\nfn media_to_content_block_json(media: &BamlMedia) -> Result<serde_json::Value> {\n    let content_block = {\n        let mut obj = Map::new();\n        if let Some(mime) = media.mime_type.as_deref() {\n            obj.insert(\"format\".into(), json!(strip_mime_prefix(mime)));\n        }\n        let source = match &media.content {\n            BamlMediaContent::File(media_file) => todo!(),\n            BamlMediaContent::Url(url) => {\n                let parsed = Url::parse(&url.url).with_context(|| {\n                    format!(\"Invalid S3 URI for AWS Bedrock video source: {url}\")\n                })?;\n\n                if parsed.scheme() != \"s3\" {\n                    anyhow::bail!(\"AWS Bedrock requires s3:// URIs, but got: {}\", url.url);\n                }\n\n                // unimplemented!(\"make sure the test works\")\n                json!({\n                    \"s3Location\": {\n                        \"uri\": url.url,\n                    }\n                })\n            }\n            BamlMediaContent::Base64(base64) => json!({\n                \"bytes\": base64.base64,\n            }),\n        };\n        obj.insert(\"source\".into(), source);\n        obj\n    };\n    match media.media_type {\n        // _ => anyhow::bail!(\"AWS Bedrock only supports base64 image inputs in modular requests\"),","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs#L71-L107","documentation":"media_to_content_block_json validates that any URL-referenced media sent to AWS Bedrock modular requests uses an s3:// URI, because the Converse API S3Location source only accepts S3 URIs. If the URL scheme is anything else (https://, http://, file://, typoed s3:/), the client bails with this error before making the API call.","triggerScenarios":"Passing a media part with BamlMediaContent::Url whose url does not start with s3:// (e.g. a public https URL or a malformed 's3:/bucket/key') while targeting an aws-bedrock client.","commonSituations":"Reusing prompt media (https URLs) that worked with OpenAI/Anthropic providers on a Bedrock client; writing S3 URIs without the double slash; referencing presigned CloudFront URLs instead of S3 URIs.","solutions":["Upload the media to S3 and reference it as s3://bucket-name/key (with a valid bucket in the same region the model is invoked in).","Or send the media as a base64 data URL so it goes through the bytes path instead of s3Location.","Verify the URI parses and has scheme 's3' before calling the client (note: a bare bucket name is not valid; the scheme must be s3)."],"exampleFix":"// before\nmedia video \"https://mybucket.s3.amazonaws.com/clip.mp4\"\n// after\nmedia video \"s3://mybucket/clip.mp4\"","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\nurl = media['content']['url']\nif urlparse(url).scheme != 's3':\n    raise ValueError(f\"Bedrock video source must be s3:// URI, got {url}\")","typeGuard":"def is_s3_uri(u: str) -> bool:\n    return u.lower().startswith('s3://')","tryCatchPattern":null,"preventionTips":["Standardize on s3://bucket/key URIs for URL-based media on Bedrock","Upload https-hosted media to S3 (or base64-inline it) when switching providers to aws-bedrock","Add a prompt-level test that renders media with the aws-bedrock client"],"tags":["aws","bedrock","s3","url","validation"],"backgroundTag":"invalid-url-format","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"}