{"record":{"id":"34a88cc7323e6e2f","repo":"BigPizzaV3/CodexPlusPlus","slug":"dreamskin-34a88c","errorCode":null,"errorMessage":"DreamSkin 主题包身份与审核元数据不一致","messagePattern":"DreamSkin 主题包身份与审核元数据不一致","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_community.rs","lineNumber":185,"sourceCode":"        metadata.package_bytes,\n        \"application/zip\",\n    )\n    .await?;\n    if package.len() != metadata.package_bytes {\n        bail!(\"DreamSkin 主题包实际大小与审核元数据不一致\");\n    }\n    let actual_sha = format!(\"{:x}\", Sha256::digest(&package));\n    if !actual_sha.eq_ignore_ascii_case(&metadata.package_sha256) {\n        bail!(\"DreamSkin 主题包 SHA-256 与审核元数据不一致\");\n    }\n    let validated = crate::dream_skin_package::validate_and_read_package(\n        &package,\n        if cfg!(windows) { \"windows\" } else { \"macos\" },\n    )?;\n    if validated.manifest.theme_id != metadata.theme_id\n        || validated.manifest.version != metadata.version\n    {\n        bail!(\"DreamSkin 主题包身份与审核元数据不一致\");\n    }\n    crate::dream_skin_library::save_validated_dream_skin_package(state_dir, &validated)\n}\n\npub fn import_theme_package(\n    state_dir: &Path,\n    archive_path: &Path,\n) -> anyhow::Result<DreamSkinThemeSummary> {\n    let metadata = std::fs::symlink_metadata(archive_path)\n        .with_context(|| format!(\"无法读取主题包：{}\", archive_path.display()))?;\n    if !metadata.file_type().is_file()\n        || metadata.file_type().is_symlink()\n        || metadata.len() == 0\n        || metadata.len() as usize > PACKAGE_BYTES_LIMIT\n    {\n        bail!(\"主题包必须是 32 MiB 以内的普通 ZIP 文件\");\n    }\n    let bytes = std::fs::read(archive_path)","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_community.rs#L167-L203","documentation":"install_community_theme verifies that the downloaded DreamSkin theme package's manifest (theme_id and version) exactly matches the community metadata that was fetched from the service. If the package contents claim a different identity than the reviewed/indexed metadata, the install is aborted to prevent installing unvetted content. This is an anti-tampering consistency check between the package and its audit record.","triggerScenarios":"Calling install_community_theme where the ZIP's internal manifest.theme_id differs from metadata.theme_id, or manifest.version differs from metadata.version (e.g. the maintainer published a new package under the same metadata, or a re-packed/tampered archive was uploaded).","commonSituations":"Upstream re-uploaded a package with a bumped version but the catalog still serves stale metadata; a malicious mirror swaps the archive; local cache of the package is from an older release; CDN serves inconsistent objects.","solutions":["Refetch the community catalog so metadata matches the current package, then retry install_community_theme.","Delete any cached/queued package bytes for this theme and download a fresh copy.","Report the theme to the DreamSkin community maintainers as having package/metadata drift.","If you maintain the mirror, regenerate the package_sha256 and version fields together so they stay consistent."],"exampleFix":"// before: using stale cached metadata\nlet metadata = cached_catalog.find(id)?.clone();\ninstall_community_theme(state_dir, &metadata).await?;\n// after: refresh metadata first\nlet catalog = load_community_catalog(state_dir, true).await?;\nlet metadata = catalog.items.iter().find(|t| t.id == id).unwrap().clone();\ninstall_community_theme(state_dir, &metadata).await?;","handlingStrategy":"validation","validationCode":"// Rust\nif theme.manifest.theme_id != metadata.theme_id || theme.manifest.version != metadata.version {\n    // skip install; refetch catalog metadata first\n}","typeGuard":"fn metadata_matches(m: &ThemeManifest, meta: &CommunityThemeMeta) -> bool {\n    m.theme_id == meta.theme_id && m.version == meta.version\n}","tryCatchPattern":"// Rust\nmatch install_community_theme(state_dir, &metadata).await {\n    Ok(v) => println!(\"installed {}\", v.theme_id),\n    Err(e) if e.to_string().contains(\"不一致\") => refresh_catalog_and_retry().await,\n    Err(e) => return Err(e),\n}","preventionTips":["Always fetch metadata and package in the same session from the same source","Re-download the package if the catalog was refreshed in between","Don't cache metadata across app restarts without revalidating sha256"],"tags":["validation","integrity","package-management"],"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"}