Zackriya-Solutions/meetily · warning

At least one model must be defined

Error message

At least one model must be defined

What it means

get_default_model takes the first element of get_available_models() and expects the list non-empty. The catalog is a hard-coded Vec of four GGUF models, so with the current code this cannot fail; the expect becomes live the moment the catalog turns dynamic (feature-gated builds, runtime config, user filtering) and yields zero entries.

Source

Thrown at frontend/src-tauri/src/summary/summary_engine/models.rs:231

            context_size: 32768,
            layer_count: 26,
            sampling: SamplingParams::gemma3_instruct(vec!["<end_of_turn>".to_string()]),
            description: "Fastest model. Runs on any hardware with ~1GB RAM. Good for quick summaries.".to_string(),
        },
    ]
}

/// Get a specific model by name
pub fn get_model_by_name(name: &str) -> Option<ModelDef> {
    get_available_models().into_iter().find(|m| m.name == name)
}

/// Get the default model (first in list)
pub fn get_default_model() -> ModelDef {
    get_available_models()
        .into_iter()
        .next()
        .expect("At least one model must be defined")
}

/// Resolve model name to full file path in the models directory
pub fn get_model_path(app_data_dir: &PathBuf, model_name: &str) -> Result<PathBuf> {
    let model = get_model_by_name(model_name)
        .ok_or_else(|| anyhow!("Unknown model: {}", model_name))?;

    let models_dir = get_models_directory(app_data_dir);
    let model_path = models_dir.join(&model.gguf_file);

    Ok(model_path)
}

/// Get the models directory path for built-in AI
pub fn get_models_directory(app_data_dir: &PathBuf) -> PathBuf {
    app_data_dir.join("models").join("summary")
}

View on GitHub (pinned to 0281737d87)

Solutions

  1. Add a unit test asserting !get_available_models().is_empty() so the invariant is checked in CI
  2. Change the signature to Result<ModelDef> (anyhow "model catalog is empty") and propagate to callers
  3. If kept panic-free, guarantee a fallback entry at compile time (const-assert the literal list length > 0)

Example fix

// before
pub fn get_default_model() -> ModelDef {
    get_available_models().into_iter().next()
        .expect("At least one model must be defined")
}

// after
pub fn get_default_model() -> anyhow::Result<ModelDef> {
    get_available_models().into_iter().next()
        .ok_or_else(|| anyhow::anyhow!("model catalog is empty"))
}

#[test]
fn catalog_never_empty() {
    assert!(!get_available_models().is_empty());
}
Defensive patterns

Strategy: validation

Validate before calling

#[test]
default_model_exists() {
    assert!(!summary_engine::models::get_available_models().is_empty());
}

Prevention

When it happens

Trigger: Refactoring get_available_models to read from config or feature flags and returning an empty Vec (e.g. a slim build with all downloadable models gated off), or filtering the list by user settings that exclude everything before calling get_default_model.

Common situations: Slim/no-network build variants, unit tests constructing empty catalogs, catalog refactors that forget a fallback entry.

Related errors


AI-assisted analysis of Zackriya-Solutions/meetily@0281737d87 (2026-08-16). Data as JSON: /api/errors/03b75efea648ba80. Report an issue: GitHub.