{"record":{"id":"2bb3ac23942da785","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-2bb3ac","errorCode":null,"errorMessage":"主题市场缓存超过大小限制","messagePattern":"主题市场缓存超过大小限制","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/codex-plus-core/src/dream_skin_market.rs","lineNumber":294,"sourceCode":"        bytes.extend_from_slice(&chunk);\n    }\n    if bytes.is_empty() {\n        bail!(\"下载内容为空\");\n    }\n    Ok(bytes)\n}\n\nfn cache_manifest(state_dir: &Path, manifest: &DreamSkinMarketManifest) -> anyhow::Result<()> {\n    let bytes = serde_json::to_vec_pretty(manifest)?;\n    crate::settings::atomic_write(&state_dir.join(MARKET_CACHE_FILE), &bytes)\n}\n\nfn read_cached_manifest(state_dir: &Path) -> anyhow::Result<DreamSkinMarketManifest> {\n    let path = state_dir.join(MARKET_CACHE_FILE);\n    let metadata = std::fs::metadata(&path)\n        .with_context(|| format!(\"主题市场缓存不存在：{}\", path.display()))?;\n    if metadata.len() > MARKET_INDEX_LIMIT as u64 {\n        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!(\"不支持的主题市场安装记录版本\");","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_market.rs#L276-L312","documentation":"`read_cached_manifest` loads the locally cached theme-market index from the state directory. Before parsing, it checks the file's size on disk against `MARKET_INDEX_LIMIT` and refuses to read a cache that exceeds it, guarding against memory blowups and poisoned/corrupted cache files. Callers of `load_market` typically fall back to fetching a fresh manifest from the network when the cache read fails.","triggerScenarios":"`load_market` invokes `read_cached_manifest` and the cache file (state_dir + market cache path) has `metadata.len()` greater than `MARKET_INDEX_LIMIT` bytes — e.g. the cache was written by another tool, corrupted, or the manifest genuinely grew past the cap.","commonSituations":"State directory manually edited or restored from a backup containing a huge file; disk corruption; a forked/modified version of the app writing unlimited manifests; syncing the state dir across machines where an unrelated file took the cache filename's place.","solutions":["Delete the oversized cache file in the state directory so `load_market` re-fetches a fresh, valid manifest from the network.","Check what wrote the file: if a backup/restore or sync tool replaced it, restore the correct cache or let it regenerate.","If your market legitimately serves an index larger than `MARKET_INDEX_LIMIT`, raise that constant in `dream_skin_market.rs`.","Verify the manifest JSON itself is valid and reasonably sized (`wc -c` on the cache file) before re-caching it."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"let path = state_dir.join(MARKET_CACHE_FILE);\nif let Ok(meta) = std::fs::metadata(&path) {\n    if meta.len() > MARKET_INDEX_LIMIT as u64 {\n        let _ = std::fs::remove_file(&path); // let load_market refetch\n    }\n}","typeGuard":null,"tryCatchPattern":"match load_market(state_dir).await {\n    Err(e) if e.to_string().contains(\"缓存超过大小限制\") => {\n        let _ = std::fs::remove_file(state_dir.join(MARKET_CACHE_FILE));\n        let fresh = load_market(state_dir).await?; // refetch from network\n    }\n    other => other?,\n}","preventionTips":["Never hand-edit or replace files in the app state directory","Exclude the state/cache directory from backup-restore and sync tools, or restore it as a unit","Treat cache read failures as non-fatal and always fall back to a network refresh","Alert when cache files grow abnormally (disk corruption indicator)"],"tags":["cache","file-size","validation","state-directory"],"backgroundTag":"file-size-limit-exceeded","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"}