{"record":{"id":"19feb012386ce41b","repo":"BoundaryML/baml","slug":"baml-fetch-as-expects-1-argument-url-got-at","errorCode":null,"errorMessage":"baml.fetch_as expects 1 argument (url), got {} at {:?}","messagePattern":"baml\\.fetch_as expects 1 argument \\(url\\), got (.+?) at (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-compiler/src/thir/interpret.rs","lineNumber":2736,"sourceCode":"                    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\" => {\n            if args.len() != 1 {\n                bail!(\n                    \"baml.fetch_as expects 1 argument (url), got {} at {:?}\",\n                    args.len(),\n                    meta.0\n                );\n            }\n            if type_args.len() != 1 {\n                bail!(\n                    \"baml.fetch_as expects 1 type argument, got {} at {:?}\",\n                    type_args.len(),\n                    meta.0\n                );\n            }\n\n            let url = match &args[0] {\n                BamlValueWithMeta::String(s, _) => s.clone(),\n                _ => bail!(\n                    \"baml.fetch_as expects a string URL argument at {:?}\",\n                    meta.0","sourceCodeStart":2718,"sourceCodeEnd":2754,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-compiler/src/thir/interpret.rs#L2718-L2754","documentation":"Thrown when the `baml.fetch_as` builtin is called without exactly one argument. The builtin fetches the content at a URL and interprets it as the type given by its single type argument, so it requires exactly one runtime argument (the url).","triggerScenarios":"Calling baml.fetch_as<T>() with 0 arguments, or 2+ arguments (e.g. url plus options/headers), which the current builtin signature does not support.","commonSituations":"Passing extra fetch options positionally (timeout, headers) out of habit from other HTTP libraries, or forgetting the url argument when the type parameter is supplied but the value omitted.","solutions":["Call baml.fetch_as with exactly one argument: the URL string","Remove extra positional options; the builtin only accepts the url","If configuration is needed, set it outside the call or via supported mechanisms, not extra arguments","Check dynamically-built argument lists (spreads) so only one value is passed"],"exampleFix":"// before (BAML)\nlet data = baml.fetch_as<MyType>(url, 30);\n// after\nlet data = baml.fetch_as<MyType>(url);","handlingStrategy":"validation","validationCode":"function validateFetchAsArgs(args: unknown[]): void {\n  if (args.length !== 1) {\n    throw new Error(`baml.fetch_as expects 1 argument (url), got ${args.length}`);\n  }\n  if (typeof args[0] !== 'string') {\n    throw new Error('baml.fetch_as url must be a string');\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  data = evaluate(call);\n} catch (e) {\n  if (String(e).includes('baml.fetch_as expects 1 argument')) {\n    // drop extra positional options from the call\n  }\n  throw e;\n}","preventionTips":["Pass only the url to baml.fetch_as","Configure timeouts/headers outside positional args","Audit dynamically built call sites for arg-count drift"],"tags":["baml","builtin","arity","fetch"],"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-14T11:17:12.474Z"}