Hmbown/CodeWhale · error · anyhow::Error

A pinned automation provider requires an explicit model

Error message

A pinned automation provider requires an explicit model

What it means

save_automation validation: a record that pins a model provider (model_provider or model_provider_id set) must also carry an explicit model; a pinned provider without a model is rejected so scheduled runs can never resolve to an arbitrary default model.

Solutions

  1. Set an explicit model on the automation record before saving when a model provider (or provider id) is pinned.
  2. Clear model_provider/model_provider_id if the automation should fall back to the default route.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/tui/src/automation_manager.rs:1245 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/d06c35e3d1e81995. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/automation_manager.rs:1245

    }

    pub fn get_automation(&self, id: &str) -> Result<AutomationRecord> {
        let path = self.automation_path(id)?;
        read_automation_file(&path)
    }

    pub fn save_automation(&self, record: &AutomationRecord) -> Result<()> {
        self.with_transaction(|| self.save_automation_unlocked(record))
    }

    fn save_automation_unlocked(&self, record: &AutomationRecord) -> Result<()> {
        if record.model_provider.is_some() || record.model_provider_id.is_some() {
            if record
                .model
                .as_deref()
                .is_none_or(|model| model.trim().is_empty())
            {
                bail!("A pinned automation provider requires an explicit model");
            }
            let mut record = record.clone();
            record.schema_version = record.schema_version.max(CURRENT_AUTOMATION_SCHEMA_VERSION);
            return write_json_atomic(&self.automation_path(&record.id)?, &record);
        }
        write_json_atomic(&self.automation_path(&record.id)?, record)
    }

    pub fn list_automations(&self) -> Result<Vec<AutomationRecord>> {
        let mut out = Vec::new();
        for entry in fs::read_dir(&self.automations_dir)
            .with_context(|| format!("Failed to read {}", self.automations_dir.display()))?
        {
            let entry = entry?;
            let path = entry.path();
            if path.extension().is_none_or(|ext| ext != "json") {
                continue;
            }

View on GitHub (pinned to 73e0f67d83)