BigPizzaV3/CodexPlusPlus · error

主题包包含不支持的文件:

Error message

主题包包含不支持的文件:{name}

What it means

Every non-macos-cruft entry's base filename must appear in ALLOWED_FILES. Entries with any other name (e.g. unexpected images, scripts, nested dirs' files) are rejected with the full entry name in the message. This whitelists the exact set of files a Dream Skin package may contain.

Solutions

  1. Remove every file from the ZIP except the allowed set (background image, manifest, LICENSE.txt, manifest.sig)
  2. Rename the background image to an allowed name: background.webp, background.jpg, or background.png
  3. Check filename casing matches the whitelist exactly
  4. Rebuild the package from a clean directory containing only required files

Example fix

// before
theme.zip: bg.png, README.md
// after
theme.zip: background.png (+ manifest/LICENSE)
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED: &[&str] = &["background.webp","background.jpg","background.png","manifest.json","LICENSE.txt","manifest.sig"];
for name in entry_names {
    let base = name.rsplit('/').next().unwrap_or_default();
    if base != ".DS_Store" && !name.starts_with("__MACOSX/") && !ALLOWED.contains(&base) {
        return Err(DisallowedFile(name.to_string()));
    }
}

Try / catch

match validate_and_read_package(&bytes, platform) {
    Err(e) if e.to_string().contains("不支持的文件") => {
        let name = extract_name(&e);
        Err(UserFacingError::UnexpectedFile(name))
    }
    other => other,
}

Prevention

When it happens

Trigger: validate_and_read_package encounters a ZIP entry whose basename is not in ALLOWED_FILES (and isn't .DS_Store or under __MACOSX/). E.g. extra `preview.jpg`, `theme.css`, or a background named `bg.png` instead of an allowed name.

Common situations: Theme authors adding README, preview images, or source files to the zip; renamed background image; build artifacts sneaking into the archive; wrong file naming (case differences) for allowed files.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

        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}");
        }
        if file.is_dir() {
            entries.push((name, None));
            continue;
        }
        let base_name = name.rsplit('/').next().unwrap_or_default();
        if base_name == ".DS_Store" || name.starts_with("__MACOSX/") {
            entries.push((name, None));
            continue;
        }
        if !ALLOWED_FILES.contains(&base_name) {
            bail!("主题包包含不支持的文件:{name}");
        }
        let limit = file_limit(base_name);
        let mut content = Vec::new();
        file.take((limit + 1) as u64)
            .read_to_end(&mut content)
            .context("读取 Dream Skin ZIP 内容失败")?;
        if content.is_empty() || content.len() > limit {
            bail!("主题包文件 {name} 超过大小限制");
        }
        unpacked = unpacked.saturating_add(content.len());
        if unpacked > UNPACKED_LIMIT {
            bail!("Dream Skin 主题包解包后超过 64 MiB 限制");
        }
        entries.push((name, Some(content)));
    }

    let mut files = normalize_package_entries(entries)?;

View on GitHub (pinned to b1ed92e5e4)