cjpais/Handy · error · anyhow::Error

Failed to load canary model {}: {}

Error message

Failed to load canary model {}: {}

What it means

Thrown when CanaryModel::load cannot create the Int8 Canary ONNX session from the files at model_path. transcribe-rs returns an error when the artifacts are missing/corrupt or ONNX Runtime session creation fails; Handy wraps it with the model_id, notifies the frontend via the loading_failed model-state-changed event, and fails load_model. No engine remains loaded after this error.

Source

Thrown at src-tauri/src/managers/transcription.rs:670

                            format!("Failed to load SenseVoice model {}: {}", model_id, e);
                        emit_loading_failed(&error_msg);
                        anyhow::anyhow!(error_msg)
                    })?;
                LoadedEngine::SenseVoice(engine)
            }
            EngineType::GigaAM => {
                let engine = GigaAMModel::load(&model_path, &Quantization::Int8).map_err(|e| {
                    let error_msg = format!("Failed to load gigaam model {}: {}", model_id, e);
                    emit_loading_failed(&error_msg);
                    anyhow::anyhow!(error_msg)
                })?;
                LoadedEngine::GigaAM(engine)
            }
            EngineType::Canary => {
                let engine = CanaryModel::load(&model_path, &Quantization::Int8).map_err(|e| {
                    let error_msg = format!("Failed to load canary model {}: {}", model_id, e);
                    emit_loading_failed(&error_msg);
                    anyhow::anyhow!(error_msg)
                })?;
                LoadedEngine::Canary(engine)
            }
            EngineType::Cohere => {
                let engine = CohereModel::load(&model_path, &Quantization::Int8).map_err(|e| {
                    let error_msg = format!("Failed to load cohere model {}: {}", model_id, e);
                    emit_loading_failed(&error_msg);
                    anyhow::anyhow!(error_msg)
                })?;
                LoadedEngine::Cohere(engine)
            }
        };

        // Update the current engine and model ID
        {
            let mut engine = self.lock_engine();
            *engine = Some(loaded_engine);
        }

View on GitHub (pinned to 98a4d80cce)

Solutions

  1. Re-download Canary from the model selector after removing the broken local copy
  2. Inspect the model directory: expected .onnx files present and non-zero size
  3. Free disk space / restore quarantined files, then retry
  4. Load a Whisper model to confirm the ONNX runtime works at all
  5. Keep Handy updated so model artifacts and runtime stay compatible

Example fix

// before
let engine = CanaryModel::load(&model_path, &Quantization::Int8);

// after — distinguish "files bad" (re-download) from "runtime bad" (report)
let engine = match CanaryModel::load(&model_path, &Quantization::Int8) {
    Ok(e) => e,
    Err(e) if model_files_look_incomplete(&model_path) => {
        return Err(anyhow::anyhow!("Canary artifacts incomplete — re-download model {}: {}", model_id, e));
    }
    Err(e) => return Err(anyhow::anyhow!("Canary load failed (runtime issue): {}", e)),
};
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check Canary artifacts before load
let path = model_manager.get_model_path(model_id)?;
for entry in std::fs::read_dir(&path)?.filter_map(|e| e.ok()) {
    anyhow::ensure!(entry.metadata()?.len() > 0, "empty file: {}", entry.path().display());
}

Try / catch

match tm.load_model(&model_id) {
    Err(e) if e.to_string().contains("Failed to load canary model") => {
        model_manager.remove_local_model(&model_id)?;
        tm.load_model(&model_id)?
    }
    other => other?,
}

Prevention

When it happens

Trigger: load_model() reaches EngineType::Canary and CanaryModel::load(&model_path, &Quantization::Int8) returns Err — e.g. incomplete Canary download, deleted/moved .onnx files, ort execution-provider failure, or memory exhaustion during session init.

Common situations: Partial first download or failed upgrade download; manual tampering with the models directory; AV quarantine; transcribe-rs/ort version mismatch after updating the app; low-memory conditions on the target machine.

Related errors


AI-assisted analysis of cjpais/Handy@98a4d80cce (2026-08-16). Data as JSON: /api/errors/043e5ad8eea926ff. Report an issue: GitHub.