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

read_automation_file refuses to load an AutomationRecord whose schema_version is greater than CURRENT_AUTOMATION_SCHEMA_VERSION. This is a forward-compatibility guard: the running binary predates the file's schema and silently parsing it could misinterpret fields, so loading fails loudly instead.

Solutions

  1. Update Codewhale to a build whose CURRENT_AUTOMATION_SCHEMA_VERSION is >= the file's version.
  2. If the downgrade is intentional, move the automation file aside and re-create the automations on the old version.
  3. Hand-edit the file only if you fully understand the new schema, lowering schema_version after removing unsupported fields (risky).
Defensive patterns

Strategy: validation

Validate before calling

let rec: AutomationRecord = serde_json::from_str(&raw)?;
if rec.schema_version > CURRENT_AUTOMATION_SCHEMA_VERSION {
    // too new: refuse or route to an up-to-date binary
}

Type guard

fn load_supported(raw: &str) -> Option<AutomationRecord> {
    let rec: AutomationRecord = serde_json::from_str(raw).ok()?;
    (rec.schema_version <= CURRENT_AUTOMATION_SCHEMA_VERSION).then_some(rec)
}

Try / catch

match read_automation_file(&path) {
    Ok(r) => use(r),
    Err(e) if e.to_string().contains("newer than supported") => prompt_upgrade(),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Opening an automation JSON file written by a newer Codewhale build (higher automation schema version) with an older binary.

Common situations: Downgrading the app or switching to an older branch/release while keeping the data directory; syncing automation files from a machine running a newer version.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

        return false;
    };
    if !rest.starts_with('-') || rest.len() < 2 {
        return false;
    }
    stamp.char_indices().all(|(idx, ch)| match idx {
        8 => ch == 'T',
        18 => ch == 'Z',
        _ => ch.is_ascii_digit(),
    })
}

fn read_automation_file(path: &Path) -> Result<AutomationRecord> {
    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)
}

fn read_run_file(path: &Path) -> Result<AutomationRunRecord> {
    let raw =
        fs::read_to_string(path).with_context(|| format!("Failed to read {}", path.display()))?;
    let run: AutomationRunRecord = serde_json::from_str(&raw)
        .with_context(|| format!("Failed to parse {}", path.display()))?;
    if run.schema_version > CURRENT_RUN_SCHEMA_VERSION {
        bail!(
            "Automation run schema v{} is newer than supported v{}",
            run.schema_version,
            CURRENT_RUN_SCHEMA_VERSION

View on GitHub (pinned to 73e0f67d83)