{"record":{"id":"0cff8ac2b08d3566","repo":"Zackriya-Solutions/meetily","slug":"app-state-not-available","errorCode":null,"errorMessage":"App state not available","messagePattern":"App state not available","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/audio/import.rs","lineNumber":846,"sourceCode":"                    warn!(\"Model discovery error (continuing): {}\", e);\n                }\n\n                e.load_model(&target_model)\n                    .await\n                    .map_err(|e| anyhow!(\"Failed to load model '{}': {}\", target_model, e))?;\n            }\n\n            Ok(e)\n        }\n        None => Err(anyhow!(\"Parakeet engine not initialized\")),\n    }\n}\n\n/// Get the configured model from database\nasync fn get_configured_model<R: Runtime>(app: &AppHandle<R>, provider_type: &str) -> Result<String> {\n    let app_state = app\n        .try_state::<AppState>()\n        .ok_or_else(|| anyhow!(\"App state not available\"))?;\n\n    let result: Option<(String, String)> = sqlx::query_as(\n        \"SELECT provider, model FROM transcript_settings WHERE id = '1'\",\n    )\n    .fetch_optional(app_state.db_manager.pool())\n    .await\n    .map_err(|e| anyhow!(\"Failed to query config: {}\", e))?;\n\n    match result {\n        Some((provider, model)) => {\n            if (provider_type == \"whisper\" && (provider == \"localWhisper\" || provider == \"whisper\"))\n                || (provider_type == \"parakeet\" && provider == \"parakeet\")\n            {\n                Ok(model)\n            } else {\n                // Return default model for the requested type\n                Ok(if provider_type == \"parakeet\" {\n                    DEFAULT_PARAKEET_MODEL.to_string()","sourceCodeStart":828,"sourceCodeEnd":864,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/audio/import.rs#L828-L864","documentation":"`app.try_state::<AppState>()` returns None when no value of exactly type AppState has been registered on the Tauri Builder via `.manage()`. This is a wiring invariant, not a runtime condition: hit at import time (run_import line 636) and inside get_configured_model, it means the app was built without managing AppState, or the command ran on a test AppHandle that skipped setup.","triggerScenarios":"The tauri::Builder chain missing `.manage(state)`; state managed under a different or renamed type after a refactor; commands invoked from a mock/test AppHandle that never ran the setup that registers state.","commonSituations":"A refactor moves manage() into a conditional branch; unit tests build a bare mock app; plugin/setup ordering changes so commands can run before state is managed.","solutions":["Add `.manage(AppState { ... })` to the tauri::Builder in lib.rs, using the same construction as other working commands","Grep for existing `.manage(` calls — the state may be registered under a wrapper type after a refactor","In tests, use tauri's mock runtime with the same setup/manage calls as production","During development, prefer `app.state::<AppState>()` (panics with a clear message) to fail fast on wiring bugs"],"exampleFix":"// before\ntauri::Builder::default()\n    .invoke_handler(tauri::generate_handler![start_import])\n    .run(tauri::generate_context!())\n\n// after — register AppState on the builder\ntauri::Builder::default()\n    .setup(|app| {\n        app.manage(AppState { db_manager: init_db(app)? });\n        Ok(())\n    })\n    .invoke_handler(tauri::generate_handler![start_import])\n    .run(tauri::generate_context!())","handlingStrategy":"validation","validationCode":"// in app setup, fail fast if state wiring is broken\n.setup(|app| {\n    app.manage(AppState { db_manager });\n    assert!(app.try_state::<AppState>().is_some(), \"AppState not managed\");\n    Ok(())\n})","typeGuard":"fn app_state_managed<R: tauri::Runtime>(app: &tauri::AppHandle<R>) -> bool {\n    app.try_state::<AppState>().is_some()\n}","tryCatchPattern":"Not a catchable runtime condition in practice — if hit, fix the Builder wiring: ensure `.manage(AppState { ... })` runs exactly once in the tauri::Builder chain before any command that calls try_state.","preventionTips":["Register AppState in a single, unconditional `.manage()` call on the Builder","Use `app.state::<AppState>()` during development so wiring bugs panic early with a clear message","In tests, use tauri's mock runtime with the same manage calls as production"],"tags":["tauri","state","dependency-injection","setup","rust"],"backgroundTag":"state-not-managed","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}