BigPizzaV3/CodexPlusPlus · error

Dream Skin 主题包超过 32 MiB 限制

Error message

Dream Skin 主题包超过 32 MiB 限制

What it means

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.

Solutions

  1. Compress or downscale the background image (convert to webp at reasonable quality)
  2. Remove unnecessary assets from the ZIP (only allowed files ship anyway)
  3. Check that the bytes passed in are non-empty — fix the file read/upload path if empty
  4. If 32 MiB is genuinely needed, the package must be split or the limit raised upstream

Example fix

// before: 4K PNG background, 40 MiB zip
// after
convert background.png -resize 2560x1440 -quality 85 background.webp
Defensive patterns

Strategy: validation

Validate before calling

const PACKAGE_LIMIT: usize = 32 * 1024 * 1024;
if bytes.is_empty() || bytes.len() > PACKAGE_LIMIT {
    return Err(PackageTooLarge(bytes.len()));
}

Try / catch

match validate_and_read_package(&bytes, "windows") {
    Err(e) if e.to_string().contains("32 MiB") => {
        Err(UserFacingError::PackageTooLarge)
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling validate_and_read_package(bytes, platform) with an empty slice, or a ZIP whose total compressed size exceeds 32 MiB.

Common situations: 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.

Understand the failure class

Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/7c69b1ef7607da60. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/dream_skin_package.rs:92

}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ValidatedDreamSkinPackage {
    pub manifest: DreamSkinPackageManifest,
    pub theme: Value,
    pub image_name: String,
    pub image_bytes: Vec<u8>,
    pub css: String,
    pub manifest_bytes: Vec<u8>,
    pub license_bytes: Option<Vec<u8>>,
}

pub fn validate_and_read_package(
    bytes: &[u8],
    platform: &str,
) -> anyhow::Result<ValidatedDreamSkinPackage> {
    if bytes.is_empty() || bytes.len() > PACKAGE_LIMIT {
        bail!("Dream Skin 主题包超过 32 MiB 限制");
    }
    let mut archive =
        ZipArchive::new(Cursor::new(bytes)).context("Dream Skin 主题包不是有效 ZIP")?;
    if archive.len() == 0 || archive.len() > FILE_LIMIT {
        bail!("Dream Skin 主题包文件数量必须在 1 到 32 之间");
    }

    let mut entries = Vec::new();
    let mut unpacked = 0usize;
    for index in 0..archive.len() {
        let file = archive
            .by_index(index)
            .context("读取 Dream Skin ZIP 条目失败")?;
        let name = file.name().to_string();
        validate_archive_entry_name(&name)?;
        if file.encrypted() || file.is_symlink() {
            bail!("主题包包含加密内容或链接:{name}");
        }

View on GitHub (pinned to b1ed92e5e4)