{"record":{"id":"e58c6afe9690a3d7","repo":"BoundaryML/baml","slug":"no-candidates-found-in","errorCode":null,"errorMessage":"No candidates found in {}","messagePattern":"No candidates found in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/optimize/tui.rs","lineNumber":1580,"sourceCode":"\n/// Internal TUI runner with optional live reload\nfn run_tui_internal(storage_path: &Path, live_mode: bool) -> Result<()> {\n    let storage = OptimizationStorage::from_existing(storage_path)\n        .context(\"Failed to open optimization storage\")?;\n\n    let mut app = App::from_storage(&storage)?;\n    app.live_mode = live_mode;\n    app.storage_path_for_reload = Some(storage_path.to_path_buf());\n\n    // Load initial status and config\n    if let Ok(config) = storage.load_config() {\n        app.total_trials = config.trials;\n    }\n    app.update_status(&storage);\n\n    // In live mode, allow starting with no candidates (optimization hasn't started yet)\n    if !live_mode && app.candidates.is_empty() {\n        anyhow::bail!(\"No candidates found in {}\", storage_path.display());\n    }\n\n    // Setup terminal\n    enable_raw_mode()?;\n    let mut stdout = io::stdout();\n    execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;\n    let backend = CrosstermBackend::new(stdout);\n    let mut terminal = Terminal::new(backend)?;\n\n    // Main loop\n    let result = run_app(&mut terminal, &mut app);\n\n    // Cleanup\n    disable_raw_mode()?;\n    execute!(\n        terminal.backend_mut(),\n        LeaveAlternateScreen,\n        DisableMouseCapture","sourceCodeStart":1562,"sourceCodeEnd":1598,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/optimize/tui.rs#L1562-L1598","documentation":"The optimizer TUI displays candidate trials from a prior optimization run's storage. In non-live mode it requires at least one candidate; if the loaded storage contains none, it bails before entering the terminal UI. Live mode intentionally allows zero candidates because optimization has not started yet.","triggerScenarios":"Running the TUI (run_tui, non-live path) pointed at a storage/run directory that contains no candidate data: the run directory exists but optimization produced no trials, the storage_path is wrong/empty, or the run was created but never progressed.","commonSituations":"Inspecting a run directory that was created but whose optimization never got past the first step; pointing --storage at the wrong directory; viewing results of a crashed run that wrote no candidates.","solutions":["Check the storage_path contents and confirm it is the run directory of a completed (or in-progress) optimization with saved candidates.","Use live mode (`run_tui_live` / the live flag) if you want to watch an optimization from the start with zero candidates.","Run the optimizer again to generate candidates, then open the TUI on the resulting run directory."],"exampleFix":"// before (static TUI on empty run dir)\nrun_tui(storage_path, config)?;\n// after (live mode allows starting with no candidates)\nrun_tui_live(storage_path, config)?;","handlingStrategy":"validation","validationCode":"// Rust: ensure candidates exist before launching the static TUI\nlet candidates = count_candidates(&storage_path)?; // e.g. read candidates.json\nif candidates == 0 {\n    eprintln!(\"{} has no candidates; use live mode or run the optimizer first\", storage_path.display());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only open the static TUI on run directories from completed optimizations.","Prefer live mode when watching a run that may not have produced candidates yet.","Confirm the storage path before launching; an empty/typo path yields this error."],"tags":["optimizer","tui","empty-result-set","rust"],"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"}