BigPizzaV3/CodexPlusPlus · error
主题包文件必须全部位于根目录或唯一一层主题目录
Error message
主题包文件必须全部位于根目录或唯一一层主题目录
What it means
normalize_package_entries requires all file entries to live either entirely at the archive root or entirely inside a single one-level theme directory. Mixing root files with nested files is rejected with this message.
Solutions
- Move all files into a single theme directory (or all to the root) and repack.
- Choose one layout: either root-level files only, or one folder containing all files.
- Update your packaging script to enforce a consistent layout.
Example fix
# before: manifest.json + theme/theme.css in one archive # after: theme/manifest.json + theme/theme.css
Defensive patterns
Strategy: validation
Validate before calling
fn layout_consistent(entries: &[String]) -> bool {
let has_root = entries.iter().any(|n| !n.contains('/'));
let has_nested = entries.iter().any(|n| n.contains('/'));
!(has_root && has_nested)
} Try / catch
match validate_and_read_package(path, platform) {
Ok(pkg) => install(pkg),
Err(e) if e.to_string().contains("根目录或唯一一层主题目录") => eprintln!("use one layout: all root files or one theme dir"),
Err(e) => return Err(e),
} Prevention
- Standardize packaging layout in your build script.
- Never append loose files to an existing package.
- Review zip listing before shipping.
When it happens
Trigger: validate_and_read_package processes an archive that contains both entries without '/' (e.g. manifest.json) and entries with '/' (e.g. theme/theme.css), triggering the bail inside the root_files branch.
Common situations: Authors zipping manifest.json alongside a theme folder; appending loose files to an existing packaged archive; partially extracted and re-zipped packages.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- 主题包只能包含唯一一层主题目录
- 主题包必须是 32 MiB 以内的普通 ZIP 文件
- Dream Skin 主题包为空
- Dream Skin 主题包文件数量必须在 1 到 32 之间
- Dream Skin 主题包超过 32 MiB 限制
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/d0815864486ab21b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/dream_skin_package.rs:846
}
Ok(())
}
fn normalize_package_entries(
entries: Vec<(String, Option<Vec<u8>>)>,
) -> anyhow::Result<std::collections::BTreeMap<String, Vec<u8>>> {
let content_entries = entries
.into_iter()
.filter_map(|(name, content)| content.map(|content| (name, content)))
.collect::<Vec<_>>();
if content_entries.is_empty() {
bail!("Dream Skin 主题包为空");
}
let root_files = content_entries.iter().any(|(name, _)| !name.contains('/'));
let prefix = if root_files {
if content_entries.iter().any(|(name, _)| name.contains('/')) {
bail!("主题包文件必须全部位于根目录或唯一一层主题目录");
}
None
} else {
let prefix = content_entries[0]
.0
.split_once('/')
.map(|(prefix, _)| prefix)
.context("主题包顶级目录无效")?;
if prefix.is_empty()
|| content_entries.iter().any(|(name, _)| {
name.split_once('/').is_none_or(|(candidate, file)| {
candidate != prefix || file.is_empty() || file.contains('/')
})
})
{
bail!("主题包只能包含唯一一层主题目录");
}
Some(format!("{prefix}/"))View on GitHub (pinned to b1ed92e5e4)