{"record":{"id":"bb30d03c4c33ec35","repo":"cjpais/Handy","slug":"model-not-found-bb30d0","errorCode":null,"errorMessage":"Model not found: {}","messagePattern":"Model not found: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/managers/transcription.rs","lineNumber":504,"sourceCode":"\n        let load_start = std::time::Instant::now();\n        debug!(\"Starting to load model: {}\", model_id);\n\n        // Emit loading started event\n        let _ = self.app_handle.emit(\n            \"model-state-changed\",\n            ModelStateEvent {\n                event_type: \"loading_started\".to_string(),\n                model_id: Some(model_id.to_string()),\n                model_name: None,\n                error: None,\n            },\n        );\n\n        let model_info = self\n            .model_manager\n            .get_model_info(model_id)\n            .ok_or_else(|| anyhow::anyhow!(\"Model not found: {}\", model_id))?;\n\n        if !model_info.is_downloaded {\n            let error_msg = \"Model not downloaded\";\n            let _ = self.app_handle.emit(\n                \"model-state-changed\",\n                ModelStateEvent {\n                    event_type: \"loading_failed\".to_string(),\n                    model_id: Some(model_id.to_string()),\n                    model_name: Some(model_info.name.clone()),\n                    error: Some(error_msg.to_string()),\n                },\n            );\n            return Err(anyhow::anyhow!(error_msg));\n        }\n\n        let model_path = self.model_manager.get_model_path(model_id)?;\n\n        // Drop the current engine BEFORE building the new one so transcribe-cpp","sourceCodeStart":486,"sourceCodeEnd":522,"githubUrl":"https://github.com/cjpais/Handy/blob/fbd4e15fa14a721c66c57006ae110428b9e255b3/src-tauri/src/managers/transcription.rs#L486-L522","documentation":"Raised by the transcription engine's load_model flow when ModelManager::get_model_info(model_id) returns None — the id is not present in the model catalog at all. This is an id-resolution failure, distinct from a download-state failure: the model was never registered (or the catalog changed under the caller). A 'loading_failed' model-state-changed event is not even emitted for this branch; the error is returned directly.","triggerScenarios":"Calling load_model with a model_id that is misspelled, removed in the current catalog, or produced by a stale settings file/frontend referencing an older model list.","commonSituations":"Persisted settings from an older app version pointing at a model id that no longer exists; hand-edited config; frontend/backend version skew after a partial update; scripts invoking the load command with guessed ids.","solutions":["List available models (model manager list / model-selector UI) and use an id from that list.","If settings reference the dead id, pick a current model in the UI so the setting is re-persisted.","Update the app so frontend bindings and backend catalog agree.","Check for exact-match pitfalls: ids are case-sensitive strings, not display names."],"exampleFix":"// before\nlet info = self.model_manager.get_model_info(model_id)\n    .ok_or_else(|| anyhow::anyhow!(\"Model not found: {}\", model_id))?;\n\n// after — include the valid ids in the error so the caller can self-correct\nlet info = self.model_manager.get_model_info(model_id).ok_or_else(|| {\n    let known: Vec<_> = self.model_manager.list_models().iter().map(|m| m.id.clone()).collect();\n    anyhow::anyhow!(\"Model not found: {} (known: {:?})\", model_id, known)\n})?;","handlingStrategy":"validation","validationCode":"// Resolve the id against the live catalog before starting the load\nlet known_ids: Vec<String> = model_manager.list_models().iter().map(|m| m.id.clone()).collect();\nif !known_ids.contains(&model_id.to_string()) {\n    anyhow::bail!(\"model id '{model_id}' not in catalog; valid ids: {known_ids:?}\");\n}","typeGuard":"fn is_known_model_id(id: &str, catalog: &[ModelInfo]) -> bool {\n    catalog.iter().any(|m| m.id == id)\n}","tryCatchPattern":"match manager.load_model(model_id).await {\n    Ok(_) => Ok(()),\n    Err(e) if e.to_string().starts_with(\"Model not found\") => {\n        // stale id in settings: refresh catalog, prompt user to re-pick\n        refresh_catalog();\n        Err(e)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Drive model selection UI from the live catalog so users can only pick valid ids.","On settings load, validate persisted model ids against the current catalog and reset to a default if gone.","Treat model ids as opaque, case-sensitive strings — never reconstruct them from names."],"tags":["model","catalog","model-id","transcription"],"backgroundTag":"unknown-model-id","analyzedSha":"fbd4e15fa14a721c66c57006ae110428b9e255b3","analyzedAt":"2026-08-17T10:29:55.597Z","contentChangedAt":"2026-08-17T10:29:55.597Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}