{"record":{"id":"d1f4118a987638a0","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-d1f411","errorCode":null,"errorMessage":"不支持的主题市场安装记录版本","messagePattern":"不支持的主题市场安装记录版本","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_market.rs","lineNumber":312,"sourceCode":"        bail!(\"主题市场缓存超过大小限制\");\n    }\n    let mut manifest: DreamSkinMarketManifest =\n        serde_json::from_slice(&std::fs::read(&path)?).context(\"主题市场缓存不是有效 JSON\")?;\n    validate_manifest(&mut manifest)?;\n    Ok(manifest)\n}\n\nfn read_install_records(state_dir: &Path) -> anyhow::Result<MarketInstallRecords> {\n    let path = state_dir.join(MARKET_INSTALLS_FILE);\n    if !path.is_file() {\n        return Ok(MarketInstallRecords {\n            schema_version: market_schema_version(),\n            themes: BTreeMap::new(),\n        });\n    }\n    let records: MarketInstallRecords = serde_json::from_slice(&std::fs::read(path)?)?;\n    if records.schema_version != market_schema_version() {\n        bail!(\"不支持的主题市场安装记录版本\");\n    }\n    Ok(records)\n}\n\nfn record_market_install(state_dir: &Path, id: &str, version: &str) -> anyhow::Result<()> {\n    let mut records = read_install_records(state_dir)?;\n    records.themes.insert(id.to_string(), version.to_string());\n    let bytes = serde_json::to_vec_pretty(&records)?;\n    crate::settings::atomic_write(&state_dir.join(MARKET_INSTALLS_FILE), &bytes)\n}\n\nfn market_download_path(state_dir: &Path, id: &str, extension: &str) -> anyhow::Result<PathBuf> {\n    if !valid_theme_id(id) || !matches!(extension, \"png\" | \"jpg\" | \"gif\" | \"bmp\" | \"webp\") {\n        bail!(\"无效的市场主题下载文件名\");\n    }\n    Ok(state_dir\n        .join(\"dream-skin/market/downloads\")\n        .join(format!(\"{id}.{extension}\")))","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_market.rs#L294-L330","documentation":"`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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["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).","Reinstall your themes after resetting the ledger so `record_market_install` re-populates it with the current schema.","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.","Reproduce the mismatch deliberately to identify which app version wrote the file, then run that version's migration path if one exists."],"exampleFix":"// state_dir/dream-skin/market installs file\n// before\n{ \"schema_version\": 1, \"themes\": { ... } }\n// after\n{ \"schema_version\": 2, \"themes\": { ... } }  // or delete the file and reinstall themes","handlingStrategy":"fallback","validationCode":"let path = state_dir.join(MARKET_INSTALLS_FILE);\nif path.is_file() {\n    let v: serde_json::Value = serde_json::from_slice(&std::fs::read(&path)?)?;\n    if v.get(\"schema_version\") != Some(&serde_json::json!(market_schema_version())) {\n        // archive/backup the file, then delete it to start fresh\n    }\n}","typeGuard":null,"tryCatchPattern":"match read_install_records(state_dir) {\n    Err(e) if e.to_string().contains(\"安装记录版本\") => {\n        // back up old file, remove it, recreate with current schema\n        let _ = std::fs::rename(&path, path.with_extension(\"bak\"));\n        let records = read_install_records(state_dir)?;\n    }\n    other => other?,\n}","preventionTips":["Back up the installs file before upgrading/downgrading the app","Expect installed-theme history resets across schema-version bumps and reinstall themes afterwards","Do not hand-edit schema_version or other fields in state files","Check the release notes for migration steps when the installs schema changes"],"tags":["schema","versioning","state-directory","migration"],"backgroundTag":"schema-validation-failed","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}