{"record":{"id":"a363360358da5803","repo":"BoundaryML/baml","slug":"test-not-found-for-expr-function","errorCode":null,"errorMessage":"Test '{}' not found for expr function '{}'","messagePattern":"Test '(.+?)' not found for expr function '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/lib.rs","lineNumber":880,"sourceCode":"            let type_builder = TypeBuilder::new();\n            type_builder.add_entries(test.type_builder_contents());\n            type_builder\n                .recursive_type_aliases()\n                .lock()\n                .unwrap()\n                .extend(test.type_builder_recursive_aliases().iter().cloned());\n            type_builder\n                .recursive_classes()\n                .lock()\n                .unwrap()\n                .extend(test.type_builder_recursive_classes().iter().cloned());\n\n            return Ok(Some(type_builder));\n        }\n\n        let expr_fn = self.ir().find_expr_fn(function_name)?;\n        let test = expr_fn.find_test(test_name).ok_or_else(|| {\n            anyhow::anyhow!(\n                \"Test '{}' not found for expr function '{}'\",\n                test_name,\n                function_name\n            )\n        })?;\n\n        if test.item.1.elem.type_builder.entries.is_empty() {\n            return Ok(None);\n        }\n\n        let type_builder = TypeBuilder::new();\n        type_builder.add_entries(&test.item.1.elem.type_builder.entries);\n        type_builder\n            .recursive_type_aliases()\n            .lock()\n            .unwrap()\n            .extend(\n                test.item","sourceCodeStart":862,"sourceCodeEnd":898,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/lib.rs#L862-L898","documentation":"This error is thrown by get_test_type_builder_impl when a named test cannot be located for an expr-function in the BAML IR. The runtime looked up the expr function via find_expr_fn, then searched its attached tests with find_test(test_name) and got None, so it reports which test name and which function name were requested. It exists to surface typos/stale test references in the baml_src test definitions rather than silently returning no type builder.","triggerScenarios":"Calling get_test_type_builder (or run_test_with_expr_events, which calls it) with a test_name that is not defined under the expr function named function_name in the compiled BAML sources.","commonSituations":"Typo in the test name passed to the CLI or test runner; the test was renamed or deleted from the .baml file while an old harness still references it; running a test defined on a different function than the one given; partially generated/stale IR after editing baml_src.","solutions":["Check the test name spelling and that it is declared inside the specified expr function in your .baml files","Regenerate/refresh the BAML runtime IR (rebuild or re-run baml-cli generate) after editing baml_src","List the existing tests for the expr function and run one of those instead","If the test lives on another function, pass the correct function_name to the call"],"exampleFix":"// before\nlet tb = runtime.get_test_type_builder(\"MyFunction\", \"my_test\", &ctx).await?;\n// after\n// baml_src now defines `test my_test { ... }` inside MyFunction,\n// or the call uses the correct function name:\nlet tb = runtime.get_test_type_builder(\"MyFunction\", \"correct_test_name\", &ctx).await?;","handlingStrategy":"validation","validationCode":"// Rust: verify the test exists before requesting its type builder\nlet expr_fn = runtime.ir().find_expr_fn(function_name)?;\nif expr_fn.find_test(test_name).is_none() {\n    return Err(anyhow!(\"test '{test_name}' not defined for '{function_name}'\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep test names in a single source of truth and reference them by constant/enum in harnesses","Regenerate IR after every edit to baml_src before running tests","List available tests programmatically instead of hardcoding names"],"tags":["test-runner","resource-not-found","rust","baml"],"backgroundTag":"record-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}