{"record":{"id":"f09ade178dc4ae75","repo":"BoundaryML/baml","slug":"baml-internal-error-vertex-file-should-have-been-resolved-to","errorCode":null,"errorMessage":"BAML internal error (Vertex): file should have been resolved to base64","messagePattern":"BAML internal error \\(Vertex\\): file should have been resolved to base64","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs","lineNumber":467,"sourceCode":"}\n\nimpl ToProviderMessage for VertexClient {\n    fn to_chat_message(\n        &self,\n        mut content: serde_json::Map<String, serde_json::Value>,\n        text: &str,\n    ) -> Result<serde_json::Map<String, serde_json::Value>> {\n        content.insert(\"text\".into(), json!(text));\n        Ok(content)\n    }\n\n    fn to_media_message(\n        &self,\n        mut content: serde_json::Map<String, serde_json::Value>,\n        media: &baml_types::BamlMedia,\n    ) -> Result<serde_json::Map<String, serde_json::Value>> {\n        match &media.content {\n            BamlMediaContent::File(_) => anyhow::bail!(\n                \"BAML internal error (Vertex): file should have been resolved to base64\"\n            ),\n            BamlMediaContent::Url(data) => {\n                let mime_type = match &media.mime_type {\n                    Some(mime) if !mime.is_empty() => mime.clone(),\n                    _ => {\n                        // Provide default mime types when none specified\n                        match media.media_type {\n                            baml_types::BamlMediaType::Video => \"video/mp4\".to_string(),\n                            _ => media.mime_type_as_ok()?,\n                        }\n                    }\n                };\n                content.insert(\n                    \"fileData\".into(),\n                    json!({\n                        \"fileUri\": data.url,\n                        \"mimeType\": mime_type","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs#L449-L485","documentation":"Vertex media messages must already have file-based content resolved to base64 before request construction. If a BamlMedia still holds BamlMediaContent::File at this point, an earlier resolution pass was skipped, so BAML raises this internal-invariant error rather than sending an invalid request.","triggerScenarios":"Passing an image/audio/file media whose content is still a raw file reference (not base64) when constructing a Vertex request — i.e. the media was not run through BAML's media resolution/loading pipeline.","commonSituations":"Programmatically constructing BamlMedia objects bypassing BAML's loader, or a bug/early failure in the file-to-base64 resolution stage that wasn't reported earlier.","solutions":["Ensure media inputs go through BAML's normal resolution pipeline (e.g. baml.* image/url or file inputs are loaded before the request is built)","If constructing media programmatically, convert file content to base64 (BamlMediaContent::Url/Base64) instead of leaving it as File","Verify you're on an up-to-date BAML version; if this reproduces with standard usage, report it as a bug to the BAML maintainers"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await baml_client.MyImageFunction(input);\n} catch (err) {\n  if (String(err).includes('file should have been resolved to base64')) {\n    // This is an internal invariant: report bug / ensure media went through the loader\n    throw new Error('Media was not resolved; ensure images pass through BAML\\'s media loading, not raw BamlMedia objects');\n  }\n  throw err;\n}","preventionTips":["Always construct media inputs via BAML's public API (baml image/file helpers) so files get base64-resolved","Never hand-build BamlMedia with BamlMediaContent::File in custom integrations","Keep BAML runtime and CLI versions in sync; report occurrences as a bug"],"tags":["vertex-ai","internal-error","media","base64"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}