BoundaryML/baml · error
env.get expects exactly one argument
Error message
env.get expects exactly one argument
What it means
The built-in `env.get(name)` function in the BAML interpreter requires exactly one argument. Calling it with zero or multiple arguments bails with `env.get expects exactly one argument` before any evaluation of the arguments occurs.
Source
Thrown at engine/baml-compiler/src/thir/interpret.rs:1768
} else {
let cell = lookup_cell(scopes, name)
.with_context(|| format!("unbound variable `{}` at {:?}", name, meta.0))?;
EvalValue::Reference(cell)
}
}
Expr::Function(arity, body, meta) => {
EvalValue::Function(*arity, body.clone(), meta.clone())
}
Expr::Call {
func,
type_args,
args,
meta: _,
} => {
if let Expr::Var(func_name, _) = func.as_ref() {
if func_name == "env.get" {
if args.len() != 1 {
bail!("env.get expects exactly one argument");
}
let key_val = expect_value(
evaluate_expr(
&args[0],
scopes,
thir,
run_llm_function,
watch_handler,
function_name,
)
.await?,
)?;
let key = match key_val {
BamlValueWithMeta::String(value, _) => value,
_ => bail!("env.get argument must be a string"),
};View on GitHub (pinned to bd85ce9dee)
Solutions
- Call `env.get` with exactly one string argument
- Split multiple lookups into separate `env.get` calls, one per variable
- Check generated/templated BAML for empty or duplicated arguments
- Ensure the argument is not accidentally spread from a list
Example fix
// before
let v = env.get("A", "B");
// after
let a = env.get("A");
let b = env.get("B"); Defensive patterns
Strategy: validation
Validate before calling
// BAML: pass exactly one string argument
let v = env.get("MY_VAR"); Try / catch
// host-side
match result {
Err(e) if e.to_string().contains("env.get expects exactly one argument") => {
// fix call arity in the BAML source
}
other => other?,
} Prevention
- One env.get call per variable
- Review templated/generated BAML argument lists
- Quote variable names as string literals
When it happens
Trigger: `env.get()` with no arguments, or `env.get("A", "B")` with two or more, inside interpreted BAML code reached via `evaluate_expr_with_context`.
Common situations: Refactoring code that reads several env vars and merging the calls incorrectly; templating that splices in an empty argument list; copy-paste from languages where extra args are ignored.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- env.get argument must be a string
- baml.media.image.from_url expects 1 argument, got {} at {:?}
- baml.fetch_as expects 1 argument (url), got {} at {:?}
- environment context missing
- environment context corrupted
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/6ae8a4471b38b197.
Report an issue: GitHub.