Hmbown/CodeWhale · error · anyhow::Error

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

Error message

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

What it means

Thrown by AutomationManager::get_trigger when a persisted DelayedTriggerRecord under ~/.codewhale/automations/triggers/{trigger_id}.json declares a schema_version greater than CURRENT_TRIGGER_SCHEMA_VERSION (v1 in this build). Every trigger record is stamped with the schema version of the binary that wrote it, and this guard makes an older codewhale fail fast instead of misreading fields a newer release added or renamed. The message reports the on-disk version first and the highest supported version second.

Source

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

            fired_at: None,
            task_id: None,
            thread_id: None,
            error: None,
            parent_trigger_id: req.parent_trigger_id,
        };
        self.save_trigger(&record)?;
        Ok(record)
    }

    /// Load a trigger by id.
    pub fn get_trigger(&self, trigger_id: &str) -> Result<DelayedTriggerRecord> {
        let path = self.trigger_path(trigger_id)?;
        let raw = fs::read_to_string(&path)
            .with_context(|| format!("Trigger '{trigger_id}' not found"))?;
        let record: DelayedTriggerRecord = serde_json::from_str(&raw)
            .with_context(|| format!("Failed to parse trigger '{trigger_id}'"))?;
        if record.schema_version > CURRENT_TRIGGER_SCHEMA_VERSION {
            bail!(
                "Trigger schema v{} is newer than supported v{}",
                record.schema_version,
                CURRENT_TRIGGER_SCHEMA_VERSION
            );
        }
        Ok(record)
    }

    /// Load a trigger only when it belongs to the given session.
    ///
    /// Foreign, ownerless legacy, unreadable, and absent records share the same
    /// result so trigger existence cannot be disclosed across sessions.
    pub fn get_trigger_for_owner(
        &self,
        trigger_id: &str,
        owner_session_id: &str,
    ) -> Result<DelayedTriggerRecord> {
        self.get_trigger(trigger_id)

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Upgrade codewhale to at least the version that wrote the record (the first version number in the message is the on-disk schema).
  2. If you must stay on the older build, archive or delete the offending file at ~/.codewhale/automations/triggers/{trigger_id}.json; that pending continuation will be lost.
  3. Use a separate state directory per codewhale version so an older binary never reads records from a newer one.

Example fix

// before
let record = manager.get_trigger(trigger_id)?;

// after: surface an upgrade hint instead of a raw load failure
let record = match manager.get_trigger(trigger_id) {
    Ok(record) => record,
    Err(err) if err.to_string().contains("newer than supported") => {
        anyhow::bail!("trigger '{trigger_id}' was written by a newer codewhale; upgrade or remove its JSON file")
    }
    Err(err) => return Err(err),
};
Defensive patterns

Strategy: try-catch

Validate before calling

fn trigger_schema_readable(path: &std::path::Path, supported: u32) -> bool {
    std::fs::read(path)
        .ok()
        .and_then(|raw| serde_json::from_slice::<serde_json::Value>(&raw).ok())
        .map(|v| v["schema_version"].as_u64().unwrap_or(0) <= supported as u64)
        .unwrap_or(false)
}

Try / catch

Match the anyhow error on the "newer than supported" substring: report an upgrade instruction (or skip the record in listings) instead of retrying; propagate every other load error unchanged.

Prevention

When it happens

Trigger: Calling get_trigger (directly or via get_trigger_for_owner, cancel_trigger_for_owner, collect_due_triggers, or trigger listings) on a trigger JSON file whose schema_version field exceeds the compiled constant — i.e. a record written by a newer codewhale release that bumped the trigger schema.

Common situations: Downgrading codewhale after a newer version scheduled delayed triggers; copying or syncing ~/.codewhale from a machine running a newer build; running a beta channel that wrote newer-schema records and then reverting to stable.

Related errors


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