BoundaryML/baml · error · AccessError
Function not found
Error message
Function not found: {expected} What it means
AccessError::FunctionNotFound is returned when looking up a named function on the heap and no function with that name exists. `expected` is the function name; this indicates the symbol table/script context lacks the function the caller tried to resolve.
Solutions
- Verify the function exists (list/lookup function symbols) before invoking
- Correct the function name string used at the call site
- Ensure the script defining the function is loaded/registered before lookup
- Handle the error gracefully (skip optional hooks) when the function may legitimately be absent
Example fix
// before
let f = heap.get_function("on_event")?; // not defined
// after
match heap.get_function("on_event") {
Ok(f) => call(f),
Err(AccessError::FunctionNotFound { expected }) => log::debug!("optional hook {expected} absent"),
Err(e) => return Err(e),
} Defensive patterns
Strategy: try-catch
Validate before calling
if !heap.has_function("on_event") {
return Ok(()); // optional hook: skip silently
} Try / catch
match heap.get_function("on_event") {
Ok(f) => call(f),
Err(AccessError::FunctionNotFound { expected }) => { log::debug!("function {expected} not defined"); skip(); },
Err(e) => return Err(e),
} Prevention
- Verify function presence before invoking optional hooks
- Centralize function-name constants and test them against loaded scripts
- Ensure scripts are fully loaded/registered before VM callbacks resolve names
When it happens
Trigger: Resolving/calling a function by name via BexHeap accessors where the name was never defined, was removed by a script reload, or is misspelled/case-mismatched.
Common situations: Calling into user script code that no longer defines the function after an edit; wrong module/scope for the lookup; typos in function-name constants.
Related errors
- Field not found: expected
- Invalid handle: expected
- Type mismatch: expected
- baml.panics.AssertionFailed
- baml.panics.Cancelled
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/2e155578681c68a3.
Report an issue: GitHub.
Appendix: source
Thrown at baml_language/crates/bex_heap/src/accessor.rs:27
use bex_vm_types::{HeapPtr, Object, PermitProof, Value};
use crate::BexHeap;
#[derive(Debug, PartialEq, thiserror::Error, Clone)]
pub enum AccessError {
#[error("Invalid handle: expected {expected}")]
InvalidHandle { expected: &'static str },
#[error("Type mismatch: expected {expected}, got {actual}")]
TypeMismatch {
expected: &'static str,
actual: String,
},
#[error("Field not found: expected {expected}")]
FieldNotFound { expected: String },
#[error("Function not found: {expected}")]
FunctionNotFound { expected: String },
#[error("Cannot convert to owned: {reason}")]
CannotConvertToOwned { reason: String },
}
pub enum BexValue<'a> {
ExternalValue(&'a BexExternalValue),
HeapPtr(&'a HeapPtr),
Value(&'a Value),
OwnedValue(Value),
}
impl<'a> From<&'a BexExternalValue> for BexValue<'a> {
fn from(value: &'a BexExternalValue) -> Self {
BexValue::ExternalValue(value)
}
}View on GitHub (pinned to bd85ce9dee)