{"record":{"id":"98698a2f4537230b","repo":"BigPizzaV3/CodexPlusPlus","slug":"manifest-files-98698a","errorCode":null,"errorMessage":"manifest.files 包含无效条目","messagePattern":"manifest\\.files 包含无效条目","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":1108,"sourceCode":"    css_bytes: &[u8],\n    image_name: &str,\n    image_bytes: &[u8],\n    license_bytes: Option<&[u8]>,\n) -> anyhow::Result<()> {\n    let mut seen = HashSet::new();\n    for file in &manifest.files {\n        if !seen.insert(file.path.as_str())\n            || !ALLOWED_FILES.contains(&file.path.as_str())\n            || matches!(file.path.as_str(), \"manifest.json\" | \"manifest.sig\")\n            || file.bytes == 0\n            || file.bytes > file_limit(&file.path)\n            || file.sha256.len() != 64\n            || !file\n                .sha256\n                .bytes()\n                .all(|b| b.is_ascii_digit() || (b'a'..=b'f').contains(&b))\n        {\n            bail!(\"manifest.files 包含无效条目\");\n        }\n        let bytes = match file.path.as_str() {\n            \"manifest.json\" => manifest_bytes,\n            \"theme.json\" => theme_bytes,\n            \"theme.css\" => css_bytes,\n            path if path == image_name => image_bytes,\n            \"LICENSE.txt\" => license_bytes.context(\"manifest 声明了 LICENSE.txt 但包内缺失\")?,\n            \"manifest.sig\" => continue,\n            _ => continue,\n        };\n        let expected_media_type = match file.path.as_str() {\n            \"theme.json\" => \"application/json\",\n            \"theme.css\" => \"text/css\",\n            \"background.webp\" => \"image/webp\",\n            \"background.jpg\" => \"image/jpeg\",\n            \"background.png\" => \"image/png\",\n            \"LICENSE.txt\" => \"text/plain\",\n            _ => \"\",","sourceCodeStart":1090,"sourceCodeEnd":1126,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L1090-L1126","documentation":"validate_manifest_files validates each entry of manifest.files before hashing: the path must be unique and in the allowed list, must not re-declare manifest.json/manifest.sig, byte size must be >0 and within the per-file limit, and sha256 must be exactly 64 lowercase-hex characters. Any entry violating these rules triggers this error.","triggerScenarios":"Calling validate_and_read_package where manifest.files contains a duplicate path, an unknown path not in ALLOWED_FILES, an entry for manifest.json or manifest.sig, bytes == 0, bytes exceeding the per-file limit, or a sha256 that is not 64 lowercase hex chars.","commonSituations":"Generating sha256 with an uppercase-only or truncated hash; listing a 0-byte placeholder file; adding a custom extra file not in the allowed set; duplicating theme.json entries; declaring manifest.sig as a regular file entry.","solutions":["Ensure every sha256 is exactly 64 lowercase hexadecimal characters","Remove duplicate or unknown paths; keep only allowed files (theme.json, theme.css, background.*, LICENSE.txt)","Do not list manifest.json or manifest.sig in manifest.files","Ensure each entry's bytes is > 0 and within the per-file size limit","Regenerate manifest.files with the packaging tool rather than hand-editing"],"exampleFix":"// before (manifest.json)\n\"files\": [ { \"path\": \"theme.json\", \"sha256\": \"ABC123\", \"bytes\": 0 } ]\n// after\n\"files\": [ { \"path\": \"theme.json\", \"mediaType\": \"application/json\", \"bytes\": 1024, \"sha256\": \"a3f2...64-hex...\" } ]","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set([\"theme.json\",\"theme.css\",\"background.webp\",\"background.jpg\",\"background.png\",\"LICENSE.txt\"]);\nconst seen = new Set();\nfor (const f of manifest.files) {\n  if (seen.has(f.path)) throw new Error(`duplicate path ${f.path}`);\n  seen.add(f.path);\n  if (!ALLOWED.has(f.path) || f.path === \"manifest.json\" || f.path === \"manifest.sig\") throw new Error(`disallowed path ${f.path}`);\n  if (!(f.bytes > 0)) throw new Error(`${f.path} bytes must be > 0`);\n  if (!/^[0-9a-f]{64}$/.test(f.sha256)) throw new Error(`${f.path} sha256 must be 64 lowercase hex`);\n}","typeGuard":"function isValidFileEntry(f) {\n  return typeof f.path === \"string\" && typeof f.bytes === \"number\" && f.bytes > 0 &&\n    typeof f.sha256 === \"string\" && /^[0-9a-f]{64}$/.test(f.sha256);\n}","tryCatchPattern":null,"preventionTips":["Generate manifest.files programmatically from the actual packaged file list","Never include manifest.json or manifest.sig in the files array","Lowercase sha256 digests and verify length is 64 before writing the manifest"],"tags":["validation","manifest","checksum","skin-package"],"backgroundTag":"invalid-argument-format","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"}