{"record":{"id":"6682b4fedd658ecd","repo":"BoundaryML/baml","slug":"no-tests-found-for-function","errorCode":null,"errorMessage":"No tests found for function '{}'","messagePattern":"No tests found for function '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/optimize/evaluator.rs","lineNumber":148,"sourceCode":"    ) -> Result<(CandidateScores, Vec<TestEvalResult>)> {\n        use crate::InternalRuntimeInterface;\n\n        // Get tests for this function\n        let ir = runtime.ir();\n        let function = ir\n            .walk_functions()\n            .find(|f| f.name() == function_name)\n            .with_context(|| format!(\"Function '{}' not found\", function_name))?;\n\n        let tests: Vec<_> = function\n            .elem()\n            .tests\n            .iter()\n            .filter(|t| test_filter.includes(function_name, &t.elem.name))\n            .collect();\n\n        if tests.is_empty() {\n            anyhow::bail!(\"No tests found for function '{}'\", function_name);\n        }\n\n        // Run tests\n        let mut results = Vec::new();\n        let semaphore = Arc::new(tokio::sync::Semaphore::new(self.parallel));\n\n        let mut handles = Vec::new();\n\n        for test_node in tests {\n            let test_name = test_node.elem.name.clone();\n            // Extract test inputs from the test definition\n            let test_inputs: HashMap<String, String> = test_node\n                .elem\n                .args\n                .iter()\n                .map(|(k, v)| (k.clone(), format!(\"{:?}\", v)))\n                .collect();\n","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/optimize/evaluator.rs#L130-L166","documentation":"The optimizer's evaluator runs the tests defined in the BAML project against a specific function, filtered by the provided test_filter. If, after filtering, no tests remain for the function being evaluated, it bails with this error rather than 'successfully' doing nothing. This makes it obvious that a function name/test filter combination matched nothing in the project.","triggerScenarios":"Calling evaluate (BamlEvaluator / `baml-cli optimize` evaluation) for a function_name whose `test` blocks either don't exist or are all excluded by the TestFilter (name pattern, tags, etc.).","commonSituations":"Typo in the function name passed to the evaluator/CLI; tests filtered out by tag or name-pattern filters; running optimization for a function that was renamed or deleted; a project where tests were removed but the optimize config still references them.","solutions":["Check the function name for typos against `function` declarations in your .baml files","Add one or more `test MyFunction { ... }` blocks for the function you're evaluating","Relax or fix the test filter (name pattern / tags) so it matches the existing tests","Run `baml-cli test --list` (or inspect the project) to see which functions actually have tests"],"exampleFix":"// before\nbaml-cli optimize eval --function ResumExtraction // typo\n\n// after\nbaml-cli optimize eval --function ExtractResume\n\n// and in baml_src\ntest ExtractResume {\n  functions [ExtractResume]\n  args { resume \"...\" }\n}","handlingStrategy":"validation","validationCode":"const definedFns = new Set([...src.matchAll(/^\\s*function\\s+(\\w+)/gm)].map((m) => m[1]));\nconst testedFns = new Set([...src.matchAll(/test\\s+\\w+\\s*\\{\\s*functions\\s*\\[([^\\]]+)\\]/g)].flatMap((m) => m[1].split(',').map((s) => s.trim())));\nif (!testedFns.has('ExtractResume')) throw new Error('No tests target function ExtractResume');","typeGuard":null,"tryCatchPattern":"try {\n  await evaluator.evaluate('ExtractResume', filter);\n} catch (e) {\n  if (/No tests found for function/i.test(e.message)) {\n    console.error('Add `test` blocks for this function or broaden the test filter');\n  }\n  throw e;\n}","preventionTips":["Add at least one `test` block for every `function` you plan to optimize","Verify function names with your editor's BAML autocomplete before running the optimizer","When filtering by tags, confirm the tag actually exists on some test","Re-check optimize configs after renaming or deleting functions"],"tags":["baml","testing","optimizer","not-found"],"backgroundTag":"entity-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}