BoundaryML/baml · error · anyhow::Error
Missing required parameter: {param_name}
Error message
Missing required parameter: {param_name} What it means
BAML's `check_function_params` validates that every non-optional parameter of a BAML function is present in the supplied argument map. When a parameter with no default and not declared optional (`T?`) is missing, the error 'Missing required parameter: <name>' is collected into the scope and returned as an anyhow error.
Source
Thrown at engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:976
for (param_name, param_type) in function_params {
scope.push(param_name.to_string());
if let Some(param_value) = params.get(param_name.as_str()) {
if let Ok(baml_arg) =
coerce_settings.coerce_arg(self, param_type, param_value, &mut scope)
{
baml_arg_map.insert(param_name.to_string(), baml_arg);
}
} else {
// Check if the parameter is optional.
if !param_type.is_optional() {
scope.push_error(format!("Missing required parameter: {param_name}"));
}
}
scope.pop(false);
}
if scope.has_errors() {
Err(anyhow::anyhow!(scope))
} else {
Ok(baml_arg_map)
}
}
fn get_dummy_args(
&self,
indent: usize,
allow_multiline: bool,
params: &BamlMap<String, TypeIR>,
) -> String {
params
.iter()
.map(|(param_name, param_type)| get_dummy_field(self, indent, param_name, param_type))
.collect::<Vec<_>>()
.join("\n")
}
}View on GitHub (pinned to bd85ce9dee)
Solutions
- Pass a value for the parameter named in the error when invoking the function
- Declare the parameter optional in .baml (`param: string?` or with a default) if it is legitimately omittable
- Regenerate the client/SDK after .baml signature changes so new required params are visible
- Audit call sites for conditionally-built argument objects and ensure all required keys are always set
Example fix
// before (.baml)
function Greet(user_name: string) { ... }
// baml_client.call("Greet", {}) // missing user_name
// after (caller)
baml_client.call("Greet", { "user_name": "alice" }) Defensive patterns
Strategy: validation
Validate before calling
function assertRequiredParams(params: Record<string, unknown>, required: string[]): void {
for (const name of required) {
if (!(name in params) || params[name] === undefined) {
throw new Error(`Missing required parameter: ${name}`);
}
}
}
// call before baml_client.call(fnName, params) Try / catch
try {
const res = await baml_client.call('FnName', params);
} catch (e) {
if (String(e).includes('Missing required parameter:')) {
const missing = String(e).match(/Missing required parameter: (\w+)/)?.[1];
console.error(`Provide a value (or make optional in .baml) for: ${missing}`);
}
throw e;
} Prevention
- Regenerate clients whenever the .baml signature changes
- Treat non-optional, default-less params as always-present in argument builders
- Declare truly optional params as `T?` in .baml
- Lint call sites against the function's declared inputs
When it happens
Trigger: Calling a BAML function (via test runner, client, or runtime arg evaluation) with a params map that omits a parameter declared as required (non-optional) in the .baml function signature.
Common situations: Forgetting to pass a newly-added function parameter after editing the .baml file; client SDK generated before the parameter was added; conditionally omitting an argument in code thinking it was optional; null vs absent confusion for optional params.
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
- Template string '{}' expects {} arguments, but {} were provi
- missing parameter: {name}
- dependency name `{name}` is reserved
- --json-args must be a JSON object, got: {json}
- {0}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/11e47f57781a7ffe.
Report an issue: GitHub.