Hmbown/CodeWhale · error · anyhow::Error

Automation schema v{} is newer than supported v{}

Error message

Automation schema v{} is newer than supported v{}

What it means

get_automation loads a single automation JSON and refuses records whose schema_version exceeds CURRENT_AUTOMATION_SCHEMA_VERSION (currently 1). The file was written by a newer Codewhale build whose record format this binary cannot interpret; the file is left on disk untouched.

Source

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

            status,
            created_at: now,
            updated_at: now,
            next_run_at,
            last_run_at: None,
        };

        self.save_automation(&record)?;
        Ok(record)
    }

    pub fn get_automation(&self, id: &str) -> Result<AutomationRecord> {
        let path = self.automation_path(id)?;
        let raw = fs::read_to_string(&path)
            .with_context(|| format!("Failed to read automation {}", path.display()))?;
        let record: AutomationRecord = serde_json::from_str(&raw)
            .with_context(|| format!("Failed to parse automation {}", path.display()))?;
        if record.schema_version > CURRENT_AUTOMATION_SCHEMA_VERSION {
            bail!(
                "Automation schema v{} is newer than supported v{}",
                record.schema_version,
                CURRENT_AUTOMATION_SCHEMA_VERSION
            );
        }
        Ok(record)
    }

    pub fn save_automation(&self, record: &AutomationRecord) -> Result<()> {
        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?;

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Upgrade the binary to at least the version that wrote the record
  2. Inspect the JSON to confirm schema_version and decide whether the record is expendable
  3. Delete or archive the offending record if it is not needed
  4. Pin one version across machines sharing the automations directory

Example fix

// before: record written by a newer build
{ "schema_version": 2, "id": "auto_...", "rrule": "FREQ=HOURLY;INTERVAL=1" }

// after: reopen with the newer binary, or archive the file
// (do not hand-lower schema_version unless the fields truly match v1)
Defensive patterns

Strategy: type-guard

Validate before calling

fn automation_record_loadable(path: &std::path::Path) -> Result<bool, anyhow::Error> {
    let raw = std::fs::read_to_string(path)?;
    let probe: serde_json::Value = serde_json::from_str(&raw)?;
    Ok(probe.get("schema_version").and_then(|v| v.as_u64()).unwrap_or(1) <= 1)
}

Type guard

fn is_supported_automation_json(raw: &str) -> bool {
    serde_json::from_str::<serde_json::Value>(raw)
        .ok()
        .and_then(|v| v.get("schema_version").and_then(|s| s.as_u64()))
        .is_none_or(|v| v <= 1)
}

Try / catch

match manager.get_automation(id) {
    Ok(record) => { /* ... */ }
    Err(e) if e.to_string().contains("newer than supported") => {
        // Written by a newer build: ask for an upgrade, do not delete the file.
        return Err(anyhow::anyhow!("automation {id} requires a newer Codewhale"));
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Creating automations with a newer Codewhale release, then downgrading the binary and calling get_automation or update_automation in the same workspace; also hand-edited records with a bumped schema_version.

Common situations: Release rollbacks; shared workspaces edited by machines running different versions; syncing the automations directory between installs.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/85f6d9ec88cc6869. Report an issue: GitHub.