{"record":{"id":"7c69b1ef7607da60","repo":"BigPizzaV3/CodexPlusPlus","slug":"dream-skin-32-mib","errorCode":null,"errorMessage":"Dream Skin 主题包超过 32 MiB 限制","messagePattern":"Dream Skin 主题包超过 32 MiB 限制","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":92,"sourceCode":"}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub struct ValidatedDreamSkinPackage {\n    pub manifest: DreamSkinPackageManifest,\n    pub theme: Value,\n    pub image_name: String,\n    pub image_bytes: Vec<u8>,\n    pub css: String,\n    pub manifest_bytes: Vec<u8>,\n    pub license_bytes: Option<Vec<u8>>,\n}\n\npub fn validate_and_read_package(\n    bytes: &[u8],\n    platform: &str,\n) -> anyhow::Result<ValidatedDreamSkinPackage> {\n    if bytes.is_empty() || bytes.len() > PACKAGE_LIMIT {\n        bail!(\"Dream Skin 主题包超过 32 MiB 限制\");\n    }\n    let mut archive =\n        ZipArchive::new(Cursor::new(bytes)).context(\"Dream Skin 主题包不是有效 ZIP\")?;\n    if archive.len() == 0 || archive.len() > FILE_LIMIT {\n        bail!(\"Dream Skin 主题包文件数量必须在 1 到 32 之间\");\n    }\n\n    let mut entries = Vec::new();\n    let mut unpacked = 0usize;\n    for index in 0..archive.len() {\n        let file = archive\n            .by_index(index)\n            .context(\"读取 Dream Skin ZIP 条目失败\")?;\n        let name = file.name().to_string();\n        validate_archive_entry_name(&name)?;\n        if file.encrypted() || file.is_symlink() {\n            bail!(\"主题包包含加密内容或链接：{name}\");\n        }","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L74-L110","documentation":"validate_and_read_package enforces a maximum theme package size of PACKAGE_LIMIT (32 MiB). An empty byte slice or anything larger is rejected before ZIP parsing to bound memory use. This is a hard limit for Dream Skin theme packages.","triggerScenarios":"Calling validate_and_read_package(bytes, platform) with an empty slice, or a ZIP whose total compressed size exceeds 32 MiB.","commonSituations":"Theme author included high-resolution background images or extra assets pushing the ZIP over 32 MiB; empty upload due to failed file read before validation.","solutions":["Compress or downscale the background image (convert to webp at reasonable quality)","Remove unnecessary assets from the ZIP (only allowed files ship anyway)","Check that the bytes passed in are non-empty — fix the file read/upload path if empty","If 32 MiB is genuinely needed, the package must be split or the limit raised upstream"],"exampleFix":"// before: 4K PNG background, 40 MiB zip\n// after\nconvert background.png -resize 2560x1440 -quality 85 background.webp","handlingStrategy":"validation","validationCode":"const PACKAGE_LIMIT: usize = 32 * 1024 * 1024;\nif bytes.is_empty() || bytes.len() > PACKAGE_LIMIT {\n    return Err(PackageTooLarge(bytes.len()));\n}","typeGuard":null,"tryCatchPattern":"match validate_and_read_package(&bytes, \"windows\") {\n    Err(e) if e.to_string().contains(\"32 MiB\") => {\n        Err(UserFacingError::PackageTooLarge)\n    }\n    other => other,\n}","preventionTips":["Check ZIP size on disk before upload (`ls -l` / fs::metadata)","Compress backgrounds to webp and cap resolution before packaging","Reject oversized uploads client-side with a clear message before calling the library"],"tags":["validation","size-limit","zip"],"backgroundTag":"payload-too-large","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"}