BoundaryML/baml · error

Unable to resolve test params

Error message

Unable to resolve test params: {:?}

What it means

get_test_params_impl evaluates a test case's parameter expressions and collects any per-parameter errors into a map. If any parameter fails to evaluate, the runtime aggregates them and returns 'Unable to resolve test params' with a debug dump of the errors, rather than producing a partial parameter set.

Solutions

  1. Read the debug-printed errors map to see which parameters failed and why
  2. Fix the failing parameter expressions in the test case (typos, missing variables, wrong types)
  3. Ensure referenced functions/variables in test args exist in the current baml_src
  4. Re-run `baml test` locally to confirm all params resolve before CI

Example fix

// before (baml_src test)
test TestGreet {
  functions=[Greet]
  args { name = userNmae } // typo
}
// after
test TestGreet {
  functions=[Greet]
  args { name = userName }
}
Defensive patterns

Strategy: validation

Validate before calling

// Before running tests, ensure all test arg identifiers exist in baml_src
// baml-cli equivalent: `baml test --function Greet` fails fast with better messages

Try / catch

match rt.get_test_params(fn_name, test_name) {
    Ok(params) => params,
    Err(e) if e.to_string().contains("Unable to resolve test params") => {
        eprintln!("Fix test args in baml_src: {e:#}");
        std::process::exit(1);
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Running a BAML test whose parameters reference undefined variables, functions producing errors, expressions with type errors, or calls that can't be evaluated in the test context (checked path where errors is non-empty).

Common situations: Typo'd or renamed variables in test-case args, test params depending on other functions that fail, missing test inputs after refactoring function signatures.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at engine/baml-runtime/src/lib.rs:812

        let eval_ctx = ctx.eval_ctx(strict);

        match maybe_params {
            Ok((params, function_params, span)) => {
                let mut errors = Vec::new();
                let params = params
                    .into_iter()
                    .map(|(k, v)| match v {
                        Ok(v) => (k, v),
                        Err(e) => {
                            errors.push(e);
                            (k, BamlValue::Null)
                        }
                    })
                    .collect::<BamlMap<_, _>>();

                if !errors.is_empty() {
                    return Err(anyhow::anyhow!(
                        "Unable to resolve test params: {:?}",
                        errors
                    ));
                }

                self.ir()
                    .check_function_params(
                        &function_params,
                        &params,
                        internal_baml_core::ir::ArgCoercer {
                            span_path: span.map(|s| s.file.path_buf().clone()),
                            allow_implicit_cast_to_string: true,
                            skip_assert_eval: false,
                        },
                    )
                    .map(|bv| bv.into_iter().map(|(k, v)| (k, v.value())).collect())
            }
            Err(e) => Err(anyhow::anyhow!("Unable to resolve test params: {:?}", e)),

View on GitHub (pinned to bd85ce9dee)