{"record":{"id":"2673f6c3ba2ee342","repo":"BoundaryML/baml","slug":"unknownmethod","errorCode":"UnknownMethod","errorMessage":"BamlImage has no callable attribute '{args:#?}'","messagePattern":"BamlImage has no callable attribute '(.+?)'","errorType":"exception","errorClass":"minijinja::Error","httpStatus":null,"severity":"error","filePath":"engine/baml-lib/jinja-runtime/src/baml_value_to_jinja_value.rs","lineNumber":133,"sourceCode":"        )\n    }\n}\n\n// Necessary for nested instances of MinijinjaBamlImage to get rendered correctly in prompts\n// See https://github.com/BoundaryML/baml/pull/855 for explanation\nimpl std::fmt::Debug for MinijinjaBamlMedia {\n    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {\n        std::fmt::Display::fmt(self, f)\n    }\n}\n\nimpl minijinja::value::Object for MinijinjaBamlMedia {\n    fn call(\n        self: &Arc<Self>,\n        _state: &minijinja::State<'_, '_>,\n        args: &[minijinja::value::Value],\n    ) -> Result<minijinja::value::Value, minijinja::Error> {\n        Err(minijinja::Error::new(\n            minijinja::ErrorKind::UnknownMethod,\n            format!(\"BamlImage has no callable attribute '{args:#?}'\"),\n        ))\n    }\n\n    fn is_true(self: &Arc<Self>) -> bool {\n        true\n    }\n\n    fn render(self: &Arc<Self>, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        std::fmt::Display::fmt(self, f)\n    }\n}\n\n#[derive(Debug)]\npub struct MinijinjaBamlEnumType {\n    pub enum_name: String,\n    pub enum_values: IndexMap<String, MinijinjaBamlEnumValue>,","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/jinja-runtime/src/baml_value_to_jinja_value.rs#L115-L151","documentation":"BAML exposes BamlImage (media) objects to minijinja templates as MinijinjaBamlMedia, whose Object::call implementation is intentionally a stub that always fails with UnknownMethod. BamlImage instances are not callable, so any attempt to call them like a function or method in a Jinja expression raises \"BamlImage has no callable attribute '{args:#?}'\".","triggerScenarios":"Writing a template expression that invokes a BamlImage value as if it were a function or method, e.g. {{ image(...) }} or {{ image.attr(...) }}, instead of attribute-only access (image.url, image.base64, image.media_type).","commonSituations":"Prompt templates that try to post-process images (resize/convert) inside the template, or copying call syntax meant for a registered filter when the correct usage is plain attribute access.","solutions":["Do not call the image; access its attributes directly (e.g. image.base64, image.media_type) or pass the BamlImage into the LLM media field.","If you need transformation, do it in host code before injecting the image into the template.","Use a registered minijinja filter/function instead of calling the image object itself.","Check template syntax: parentheses after an image variable trigger this; remove them.","Inspect the '{args:#?}' in the message — it shows exactly what call was attempted."],"exampleFix":"// before (template)\n{{ image.resize(1024) }}\n// after\n{{ image.base64 }}  {# attribute access only; resize in host code or via a registered filter #}","handlingStrategy":"validation","validationCode":"// In templates, never invoke image objects; attribute access only.\n// Host-side guard before rendering:\nif template_src.contains(&format!(\"{{{{ {}(\", image_var)) {\n    bail!(\"{image_var} is a BamlImage and is not callable; use attribute access\");\n}","typeGuard":"// Attribute-only pattern: {{ image.base64 }} / {{ image.media_type }} — no parentheses after the image variable","tryCatchPattern":"match tpl.render(ctx) {\n    Ok(out) => out,\n    Err(e) if e.kind() == minijinja::ErrorKind::UnknownMethod =>\n        bail!(\"template called a non-callable BamlImage: {e}\"),\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Treat BamlImage values as opaque data, never as functions or filters.","Perform image transformations in host code, not in Jinja templates.","Register custom minijinja filters for any image operations you need.","Check for stray parentheses after media variables in prompt templates."],"tags":["jinja","minijinja","baml","template","unknown-method"],"backgroundTag":"unsupported-operation","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"}