BoundaryML/baml · error · EngineError

Function not found: {name}

Error message

Function not found: {name}

What it means

`EngineError::FunctionNotFound` is raised when a function name does not exist in the engine's function table. The name is resolved before any invocation is attempted; unknown names are rejected outright.

Source

Thrown at baml_language/crates/bex_engine/src/lib.rs:807

        if no_active_calls {
            self.engine.lifecycle_changed.notify_waiters();
        }
    }
}

/// Errors that can occur during engine execution.
#[derive(Debug, PartialEq, Error, Clone)]
pub enum EngineError {
    #[error("BAML engine is shutting down")]
    ShuttingDown,

    #[error("Function call with ID {call_id} not found")]
    FunctionCallNotFound { call_id: CallId },

    #[error("Future with ID {future_id} not found")]
    FutureNotFound { future_id: FutureId },

    #[error("Function not found: {name}")]
    FunctionNotFound { name: String },

    /// Function exists, but its `FunctionKind` is not invokable as an
    /// engine entry point. Only bytecode functions can be called via
    /// [`BexEngine::call_function`] / [`BexEngine::call_function_bound_args`]:
    /// native (`$rust_function`) entries would re-enter the VM through
    /// `YieldToCall` with no bytecode frame to return to. Sysops + builtins
    /// reach their natives from inside a calling bytecode body.
    #[error("Function `{name}` is not invokable as an entry point (kind: {kind})")]
    NotInvokableAsEntry { name: String, kind: String },

    #[error("VM internal error: {0}")]
    VmInternalError(bex_vm::errors::VmInternalError),

    #[error("{}", format_vm_internal_error(source, trace))]
    TracedVmInternalError {
        source: bex_vm::errors::VmInternalError,
        trace: Vec<bex_vm::StackFrame>,

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Verify the exact function name against the loaded BAML sources.
  2. Ensure the module/program defining the function was compiled and registered into this engine.
  3. Fix typos and re-run after any rename.

Example fix

// before
engine.call_function("ClassfyDoc", args).await?;
// after
engine.call_function("ClassifyDocument", args).await?;
Defensive patterns

Strategy: try-catch

Validate before calling

// rust
if !engine.has_function(name) { /* resolve before calling */ }

Try / catch

// rust
match engine.call_function(name, args).await {
    Err(EngineError::FunctionNotFound { name }) => eprintln!("unknown function: {name}"),
    other => other?,
}

Prevention

When it happens

Trigger: Calling `BexEngine::call_function` / `call_function_bound_args` with a name string that matches no registered function.

Common situations: Typo in the function name; calling a function defined in a BAML file that was not loaded/compiled into this engine; renaming a function in source without updating call sites.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/1a8e241771c29a23. Report an issue: GitHub.