BoundaryML/baml · error · VmBamlError

render prompt: {message}

Error message

render prompt: {message}

What it means

This error is produced by the RenderPrompt variant of the BAML VM error enum. It signals that the VM failed to render a prompt — i.e. interpolate/construct the final prompt text from the BAML function's prompt template, arguments, and client config — before sending it to an LLM. The library throws it because prompt rendering happens inside the BAML runtime, and any failure there (missing interpolation variable, bad template syntax, invalid function args) must be surfaced as a structured VM error.

Source

Thrown at baml_language/crates/bex_vm_types/src/errors.rs:134

    #[error("parse error: {message}")]
    ParseError { message: String },

    #[error("I/O error: {message}")]
    Io { message: String },

    #[error("timeout: {message}")]
    Timeout {
        message: String,
        duration_ms: Option<i64>,
    },

    #[error("unsupported: {message}")]
    Unsupported { message: String },

    #[error("access error: {message}")]
    AccessError { message: String },

    #[error("render prompt: {message}")]
    RenderPrompt { message: String },

    #[error("LLM client error: {message}")]
    LlmClient { message: String },

    /// An error value from the host language that has no direct BAML
    /// representation. The `handle` is the load-bearing field — it
    /// references the original host exception object via the
    /// process-global host-value table, so the originating runtime can
    /// recover the exact native exception on round-trip. The
    /// `class_name` / `message` / `language` / `traceback` fields are
    /// purely metadata for debugging, logging, and user-facing
    /// formatting — they do not participate in error matching or
    /// rehydration.
    ///
    /// Surfaces in BAML as a `baml.errors.HostCallable` Instance whose
    /// `_handle` field is materialized from `handle`. Engine-side
    /// failures with no underlying host exception (bridge serialization

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Check that every variable interpolated in the prompt template matches a declared function parameter (names and casing must match exactly).
  2. Render the template in isolation or simplify it to bisect which expression fails.
  3. Validate argument values before calling the function (no nulls where strings are expected).
  4. Regenerate client code / sync BAML sources after schema changes so the template and bindings agree.

Example fix

// before
prompt #"
  Classify {{Inptut.text}}
"#
// after (fix the parameter-name typo)
prompt #"
  Classify {{Input.text}}
"#
Defensive patterns

Strategy: validation

Validate before calling

// Rust: verify template variables exist before calling
fn assert_template_vars(template: &str, args: &[&str]) -> Result<(), String> {
    for var in extract_brace_vars(template) {
        if !args.contains(&var.as_str()) {
            return Err(format!("template var '{}' not in function args", var));
        }
    }
    Ok(())
}

Try / catch

match vm_result {
    Err(BexError::RenderPrompt { message }) => eprintln!("prompt render failed: {}", message),
    other => other?,
}

Prevention

When it happens

Trigger: Calling a BAML function whose prompt template references an undefined parameter; template syntax errors (bad {{ }} expressions, invalid Jinja); passing arguments whose types cannot be stringified into the template; render-time client/model placeholder substitution failures.

Common situations: Renaming a BAML function parameter but forgetting to update the prompt template; upgrading BAML and having deprecated template syntax; passing None/null where the template expects a string; typos in variable names inside curly braces.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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