{"record":{"id":"b71a6d7879be03c8","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-b71a6d","errorCode":null,"errorMessage":"主题包包含未处理文件","messagePattern":"主题包包含未处理文件","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":170,"sourceCode":"    if [\"background.webp\", \"background.jpg\", \"background.png\"]\n        .iter()\n        .filter(|name| files.contains_key(**name))\n        .count()\n        != 1\n    {\n        bail!(\"主题包必须且只能包含一个背景图片\");\n    }\n    let image_bytes = files.remove(&image_name).expect(\"image was checked above\");\n    validate_image_content(&image_name, &image_bytes)?;\n    let license_bytes = files.remove(\"LICENSE.txt\");\n    let signature = files.remove(\"manifest.sig\");\n    if let Some(signature) = signature {\n        if signature.len() > SIGNATURE_LIMIT {\n            bail!(\"manifest.sig 超过大小限制\");\n        }\n    }\n    if !files.is_empty() {\n        bail!(\"主题包包含未处理文件\");\n    }\n\n    let manifest: DreamSkinPackageManifest = parse_json(&manifest_bytes, \"manifest.json\")?;\n    validate_manifest(&manifest, platform)?;\n    let theme: Value = parse_json(&theme_bytes, \"theme.json\")?;\n    validate_theme(&theme, &manifest, &image_name)?;\n    let css = String::from_utf8(css_bytes).context(\"theme.css 不是有效 UTF-8\")?;\n    validate_safe_css(&css)?;\n    validate_manifest_files(\n        &manifest,\n        &manifest_bytes,\n        &theme_bytes,\n        css.as_bytes(),\n        &image_name,\n        &image_bytes,\n        license_bytes.as_deref(),\n    )?;\n","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L152-L188","documentation":"validate_and_read_package unpacks a Dream Skin ZIP, strips the known entries (manifest.json, theme.json, theme.css, one background image, optional LICENSE.txt and manifest.sig) and then asserts the file set is fully consumed. If any non-directory entry survives that removal, the package contains a file the format does not define, so it bails with '主题包包含未处理文件'. This is a last-line guard: every other stray filename should already have been caught by the ALLOWED_FILES check earlier, so reaching this point means the file had an allowed name but the wrong count/role (e.g. a second background image variant).","triggerScenarios":"Calling validate_and_read_package on a ZIP that, after removing manifest.json/theme.json/theme.css/the single image/LICENSE.txt/manifest.sig, still has entries left — e.g. a package shipping two background images (should have failed earlier with '必须且只能包含一个背景图片' if both are images, but a package with an unexpected allowed-named file the code forgot to consume), or a future/renamed entry that slipped past base-name checks.","commonSituations":"Hand-built theme packages where an author added an extra file (a second background, a README with an allowed-looking name, thumbnails); packaging tools emitting extras like .DS_Store variants in odd locations; version drift where a newer package format includes a file this client version doesn't know.","solutions":["Open the ZIP and list its entries; keep only manifest.json, theme.json, theme.css, exactly one background.{webp,jpg,png}, and optionally LICENSE.txt and manifest.sig","Repackage the theme with only the allowed files at the root (or in a single top-level directory) and retry validate_and_read_package","If the package is from a newer publisher format, upgrade the client library so the new entry is recognized and consumed"],"exampleFix":"// before: package ships background.png + background.jpg + README.md\n// after: repackage\ncargo_package/\n  manifest.json\n  manifest.sig\n  theme.json\n  theme.css\n  background.png\n  LICENSE.txt","handlingStrategy":"validation","validationCode":"fn has_only_allowed_entries(zip_names: &[&str]) -> bool {\n    const ALLOWED: &[&str] = &[\"manifest.json\",\"manifest.sig\",\"theme.json\",\"theme.css\",\"background.webp\",\"background.jpg\",\"background.png\",\"LICENSE.txt\"];\n    let files: Vec<&str> = zip_names.iter().filter(|n| !n.ends_with('/')).map(|n| n.rsplit('/').next().unwrap()).collect();\n    files.iter().all(|f| ALLOWED.contains(f))\n        && files.iter().filter(|f| f.starts_with(\"background.\")).count() == 1\n}","typeGuard":"fn is_allowed_package_file(name: &str) -> bool {\n    matches!(name, \"manifest.json\" | \"manifest.sig\" | \"theme.json\" | \"theme.css\" | \"background.webp\" | \"background.jpg\" | \"background.png\" | \"LICENSE.txt\")\n}","tryCatchPattern":"match validate_and_read_package(&bytes, platform) {\n    Ok(pkg) => install(pkg),\n    Err(e) if e.to_string().contains(\"未处理文件\") => reject_package(\"unsupported extra files in package\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Before distributing, list the archive and keep exactly manifest.json, theme.json, theme.css, one background image, and optionally LICENSE.txt/manifest.sig","Exclude OS junk (.DS_Store, __MACOSX, Thumbs.db) at packaging time with archive excludes","Validate packages with validate_and_read_package in CI before publishing"],"tags":["zip","package-validation","dream-skin"],"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"}