BoundaryML/baml · error
unknown builtin function
Error message
unknown builtin function '{}' at {:?} What it means
The BAML interpreter dispatches builtin function calls by name. When evaluate_builtin_function encounters a function name it does not recognize (not one of the implemented builtins such as baml.fetch_as), it throws this error with the name and source span.
Solutions
- Check the spelling of the function name against the documented builtin list
- Verify your BAML engine version supports the builtin; upgrade if needed
- Implement the logic as a regular BAML function or expression if no builtin exists
Example fix
// before let v = baml.fetcha_as::<T>(url) // after let v = baml.fetch_as::<T>(url)
Defensive patterns
Strategy: validation
Validate before calling
const KNOWN_BUILTINS: [&str; 1] = ["baml.fetch_as"];
fn is_known_builtin(name: &str) -> bool {
KNOWN_BUILTINS.contains(&name)
} Prevention
- Keep a list of valid builtins for your engine version
- Enable editor autocomplete for BAML builtins to avoid typos
- Pin and verify the engine version when using recently added builtins
When it happens
Trigger: Calling a function that does not exist as a builtin, e.g. a typo like baml.fetch_as2 or baml.fetc_as, or calling a function only available in a newer BAML version on an older interpreter.
Common situations: Typo in a builtin name; copying code using a builtin from newer docs than the installed engine version; assuming a helper exists when it must be defined in BAML or supplied another way.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- baml.fetch_as expects 1 type argument, got
- array assignment index out of bounds
- array assignment on non-list value at
- array assignment requires a non-negative integer index at
- assign to undeclared variable
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/2fe5d906b3a0ebb2.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-compiler/src/thir/interpret.rs:2793
"baml.fetch_as: HTTP request failed: HTTP {}\nBody: {} at {:?}",
status,
body,
meta.0
);
}
let body = response.text().await.with_context(|| {
format!(
"baml.fetch_as: failed to read response body at {:?}",
meta.0
)
})?;
// Parse the JSON body into the target type
let parsed_value = parse_json_to_baml_value(&body, target_type, meta)?;
Ok(parsed_value)
}
_ => bail!("unknown builtin function '{}' at {:?}", fn_name, meta.0),
}
}
fn evaluate_method_call(
receiver: &BamlValueWithMeta<ExprMetadata>,
method_name: &str,
args: &[BamlValueWithMeta<ExprMetadata>],
meta: &ExprMetadata,
) -> Result<BamlValueWithMeta<ExprMetadata>> {
match method_name {
"length" => {
// Array/List/String/Map length method
match receiver {
BamlValueWithMeta::List(items, _) => {
if !args.is_empty() {
bail!("length() method takes no arguments at {:?}", meta.0);
}
Ok(BamlValueWithMeta::Int(items.len() as i64, meta.clone()))View on GitHub (pinned to bd85ce9dee)