{"record":{"id":"8eb1dfb995cc5500","repo":"BoundaryML/baml","slug":"no-functions-with-tests-found-to-optimize","errorCode":null,"errorMessage":"No functions with tests found to optimize","messagePattern":"No functions with tests found to optimize","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/optimize/orchestrator.rs","lineNumber":118,"sourceCode":"            println!($($arg)*);\n        }\n    };\n}\n\nimpl GEPAOrchestrator {\n    /// Create a new orchestrator\n    pub fn new(\n        user_runtime: Arc<BamlRuntime>,\n        gepa_runtime: GEPARuntime,\n        storage: OptimizationStorage,\n        config: OrchestratorConfig,\n    ) -> Result<Self> {\n        // Find functions to optimize\n        let ir = user_runtime.ir();\n        let functions = filter_functions(ir, &config.function_filter);\n\n        if functions.is_empty() {\n            anyhow::bail!(\"No functions with tests found to optimize\");\n        }\n\n        // For now, optimize the first matching function\n        // TODO: Support optimizing multiple functions\n        let function_name = functions.into_iter().next().unwrap();\n\n        let evaluator = Evaluator::new(config.env_vars.clone(), config.parallel);\n\n        let applier = CandidateApplier::new(\n            &config.baml_src_path,\n            config.env_vars.clone(),\n            config.feature_flags.clone(),\n        );\n\n        let pareto = ParetoFrontier::new(config.objectives.clone());\n\n        Ok(Self {\n            user_runtime,","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/optimize/orchestrator.rs#L100-L136","documentation":"The BAML optimizer orchestrator requires at least one BAML function that has test cases to run optimization against. It loads the intermediate representation (IR), filters functions by the configured function_filter, and fails fast if the filtered set is empty, since there is nothing to optimize. This is a deliberate bail in `Orchestrator::new` rather than a bug.","triggerScenarios":"Calling the optimize entrypoint (Orchestrator::new) when `filter_functions(ir, &config.function_filter)` returns an empty list: no BAML functions match the filter, or the matching functions have no tests, or the BAML project has no functions at all.","commonSituations":"Running `baml optimize` (or the optimizer TUI) in a project whose baml_src contains only functions without tests; passing a --function filter name that is misspelled or does not exist; running the optimizer from the wrong directory so no BAML source is loaded.","solutions":["Add test cases (`test` blocks) to the BAML functions you want to optimize, since only functions with tests are eligible.","Check your function_filter config and remove or correct it so it matches existing function names exactly.","Run from the directory containing baml_src and verify `baml dev` lists the function you intend to optimize."],"exampleFix":"// before (filter matches nothing)\nlet config = OptimizeConfig { function_filter: vec![\"ClassifyyRequest\".to_string()], ..Default::default() };\n\n// after (exact function name that has tests)\nlet config = OptimizeConfig { function_filter: vec![\"ClassifyRequest\".to_string()], ..Default::default() };","handlingStrategy":"validation","validationCode":"// Rust: before constructing the orchestrator\nlet ir = user_runtime.ir();\nlet fns = filter_functions(ir, &config.function_filter);\nif fns.is_empty() {\n    eprintln!(\"No BAML functions with tests match filter {:?}; add tests or fix the filter\", config.function_filter);\n    return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give every optimizable BAML function at least one `test` block.","Validate function_filter names against `baml dev`'s function list before running the optimizer.","Run the optimizer from the project root so baml_src is discovered."],"tags":["optimizer","empty-result-set","rust","configuration"],"backgroundTag":"empty-result-set","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"}