BigPizzaV3/CodexPlusPlus · error

不支持的主题市场安装记录版本

Error message

不支持的主题市场安装记录版本

What it means

`read_install_records` reads the theme-market install ledger (`MARKET_INSTALLS_FILE`) and requires its `schema_version` field to equal the version this build writes (`market_schema_version()`). A mismatch means the on-disk record was produced by a different (older or newer) application version whose format cannot be safely interpreted, so the library refuses to load it.

Solutions

  1. Delete or rename the market install records file in the state directory so a fresh file with the current schema version is created (note: installed-theme history is reset).
  2. Reinstall your themes after resetting the ledger so `record_market_install` re-populates it with the current schema.
  3. If you need to keep history, hand-edit the file's `schema_version` to the current value only if the rest of the format is unchanged.
  4. Reproduce the mismatch deliberately to identify which app version wrote the file, then run that version's migration path if one exists.

Example fix

// state_dir/dream-skin/market installs file
// before
{ "schema_version": 1, "themes": { ... } }
// after
{ "schema_version": 2, "themes": { ... } }  // or delete the file and reinstall themes
Defensive patterns

Strategy: fallback

Validate before calling

let path = state_dir.join(MARKET_INSTALLS_FILE);
if path.is_file() {
    let v: serde_json::Value = serde_json::from_slice(&std::fs::read(&path)?)?;
    if v.get("schema_version") != Some(&serde_json::json!(market_schema_version())) {
        // archive/backup the file, then delete it to start fresh
    }
}

Try / catch

match read_install_records(state_dir) {
    Err(e) if e.to_string().contains("安装记录版本") => {
        // back up old file, remove it, recreate with current schema
        let _ = std::fs::rename(&path, path.with_extension("bak"));
        let records = read_install_records(state_dir)?;
    }
    other => other?,
}

Prevention

When it happens

Trigger: `enrich_market_manifest` or `record_market_install` calls `read_install_records`; the installs file exists in the state dir and deserializes as JSON, but its `schema_version` differs from `market_schema_version()` — typically after upgrading or downgrading the app, or hand-editing the file.

Common situations: Upgrading CodexPlusPlus after the install-record schema changed (old file left behind); rolling back to an older release that wrote a different version; manually editing the installs JSON and changing the version field; restoring state files from a different app 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 BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/d1f4118a987638a0. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/dream_skin_market.rs:312

        bail!("主题市场缓存超过大小限制");
    }
    let mut manifest: DreamSkinMarketManifest =
        serde_json::from_slice(&std::fs::read(&path)?).context("主题市场缓存不是有效 JSON")?;
    validate_manifest(&mut manifest)?;
    Ok(manifest)
}

fn read_install_records(state_dir: &Path) -> anyhow::Result<MarketInstallRecords> {
    let path = state_dir.join(MARKET_INSTALLS_FILE);
    if !path.is_file() {
        return Ok(MarketInstallRecords {
            schema_version: market_schema_version(),
            themes: BTreeMap::new(),
        });
    }
    let records: MarketInstallRecords = serde_json::from_slice(&std::fs::read(path)?)?;
    if records.schema_version != market_schema_version() {
        bail!("不支持的主题市场安装记录版本");
    }
    Ok(records)
}

fn record_market_install(state_dir: &Path, id: &str, version: &str) -> anyhow::Result<()> {
    let mut records = read_install_records(state_dir)?;
    records.themes.insert(id.to_string(), version.to_string());
    let bytes = serde_json::to_vec_pretty(&records)?;
    crate::settings::atomic_write(&state_dir.join(MARKET_INSTALLS_FILE), &bytes)
}

fn market_download_path(state_dir: &Path, id: &str, extension: &str) -> anyhow::Result<PathBuf> {
    if !valid_theme_id(id) || !matches!(extension, "png" | "jpg" | "gif" | "bmp" | "webp") {
        bail!("无效的市场主题下载文件名");
    }
    Ok(state_dir
        .join("dream-skin/market/downloads")
        .join(format!("{id}.{extension}")))

View on GitHub (pinned to b1ed92e5e4)