BoundaryML/baml · error

builtin function baml.fetch_value is not supported in…

Error message

builtin function baml.fetch_value is not supported in interpreter at {:?}

What it means

The builtin `baml.fetch_value` requires network/runtime value-store access, which the THIR interpreter does not implement. Encountering Builtin::FetchValue during expression evaluation unconditionally raises "builtin function baml.fetch_value is not supported in interpreter". It is a deliberate capability gap, not a bug in your expression.

Solutions

  1. Refactor to pass the value as a function argument instead of calling baml.fetch_value inside interpreted code
  2. Resolve the value outside the interpreted expression and inject it via the environment/context
  3. Run the function through the normal compiled/runtime execution path instead of the interpreter
  4. Track BAML releases for interpreter support of fetch_value and upgrade when available

Example fix

// before
fn f() { baml.fetch_value("API_KEY") }
// after
fn f(api_key: string) { api_key } // caller resolves fetch_value and passes it in
Defensive patterns

Strategy: fallback

Validate before calling

// Detect fetch_value usage before sending code to the interpreter
function usesFetchValue(code: string): boolean {
  return code.includes("baml.fetch_value");
}

Try / catch

try {
  return interpreter.run(code, env);
} catch (e) {
  if (String(e).includes("baml.fetch_value is not supported")) {
    return runViaCompiledRuntime(code, env); // fallback to full runtime
  }
  throw e;
}

Prevention

When it happens

Trigger: Any interpreted evaluation (interpreter-based tests, runtime expression evaluation) that executes code containing a baml.fetch_value call.

Common situations: Using fetch_value to read runtime-provided values (secrets, dynamic config) inside a function that is then run through the interpreter; migrating code compiled to the normal runtime into an interpreter-based path.

Related errors


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

Appendix: source

Thrown at engine/baml-compiler/src/thir/interpret.rs:2125

                                    meta.0
                                ),
                            }
                        }
                    }
                }

                EvalValue::Value(BamlValueWithMeta::Class(
                    name.clone(),
                    field_map,
                    meta.clone(),
                ))
            }
            Expr::Builtin(builtin, meta) => {
                use crate::thir::Builtin;
                match builtin {
                    Builtin::FetchValue => {
                        // FetchValue requires network access and is not supported in the interpreter
                        bail!(
                            "builtin function baml.fetch_value is not supported in interpreter at {:?}",
                            meta.0
                        )
                    }
                }
            }
            Expr::BinaryOperation {
                left,
                operator,
                right,
                meta,
            } => {
                // Special handling for instanceof: right operand is a type name, not a value
                if matches!(operator, crate::hir::BinaryOperator::InstanceOf) {
                    let left_val = expect_value(
                        evaluate_expr(
                            left,
                            scopes,

View on GitHub (pinned to bd85ce9dee)