{"record":{"id":"8d01cd6aeb69a414","repo":"BoundaryML/baml","slug":"baml-media-image-from-url-expects-1-argument-got-at","errorCode":null,"errorMessage":"baml.media.image.from_url expects 1 argument, got {} at {:?}","messagePattern":"baml\\.media\\.image\\.from_url expects 1 argument, got (.+?) at (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-compiler/src/thir/interpret.rs","lineNumber":2716,"sourceCode":"                }\n                Ok(BamlValueWithMeta::Map(baml_map, meta.clone()))\n            }\n        }\n    }\n\n    json_to_baml(&json_value, target_type, meta)\n}\n\nasync fn evaluate_builtin_function(\n    fn_name: &str,\n    args: &[BamlValueWithMeta<ExprMetadata>],\n    type_args: &[baml_types::TypeIR],\n    meta: &ExprMetadata,\n) -> Result<BamlValueWithMeta<ExprMetadata>> {\n    match fn_name {\n        \"baml.media.image.from_url\" => {\n            if args.len() != 1 {\n                bail!(\n                    \"baml.media.image.from_url expects 1 argument, got {} at {:?}\",\n                    args.len(),\n                    meta.0\n                );\n            }\n            let url = match &args[0] {\n                BamlValueWithMeta::String(s, _) => s.clone(),\n                _ => bail!(\n                    \"baml.media.image.from_url expects a string argument at {:?}\",\n                    meta.0\n                ),\n            };\n            Ok(BamlValueWithMeta::Media(\n                baml_types::BamlMedia::url(baml_types::BamlMediaType::Image, url, None),\n                meta.clone(),\n            ))\n        }\n        \"baml.fetch_as\" => {","sourceCodeStart":2698,"sourceCodeEnd":2734,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-compiler/src/thir/interpret.rs#L2698-L2734","documentation":"Thrown by the BAML interpreter's builtin-function evaluator when `baml.media.image.from_url` is called with an argument count other than exactly 1. The builtin constructs an image BamlMedia from a URL and requires exactly one string argument.","triggerScenarios":"Calling baml.media.image.from_url with 0 arguments, or with 2+ arguments (e.g. trying to pass url plus alt-text or dimensions, which this builtin does not accept).","commonSituations":"Copying a media-helper signature from another API that accepts options, adding extra positional parameters, or forgetting the url argument entirely when constructing dynamic media in prompt expressions.","solutions":["Call baml.media.image.from_url with exactly one string URL argument","Move any extra configuration (headers, alt text) out of the builtin call; it only accepts a URL","Check arity at the call site; count arguments if they are generated dynamically (e.g. spread from a list)","Consult the builtin registry for media builtins that accept extra parameters if you need them"],"exampleFix":"// before (BAML)\nlet img = baml.media.image.from_url(url, \"logo\");\n// after\nlet img = baml.media.image.from_url(url);","handlingStrategy":"validation","validationCode":"function validateImageFromUrlArgs(args: unknown[]): void {\n  if (args.length !== 1) {\n    throw new Error(`baml.media.image.from_url expects 1 argument, got ${args.length}`);\n  }\n  if (typeof args[0] !== 'string') {\n    throw new Error('baml.media.image.from_url expects a string URL');\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  img = evaluate(call);\n} catch (e) {\n  if (String(e).includes('baml.media.image.from_url expects 1 argument')) {\n    // trim extra args at the call site\n  }\n  throw e;\n}","preventionTips":["Check builtin arity in docs before adding options","Never spread variable-length arg lists into builtins","Keep media configuration out of positional builtin arguments"],"tags":["baml","builtin","arity","media"],"backgroundTag":"missing-required-argument","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"}