BigPizzaV3/CodexPlusPlus · error
主题包背景图片内容与扩展名不一致:
Error message
主题包背景图片内容与扩展名不一致:{name} What it means
validate_image_content checks magic bytes of background images against their declared file name: PNG, JPEG, GIF and WEBP signatures must match. If the bytes do not match the expected format for the entry name (or the name is not a known background image), it bails with this message.
Solutions
- Re-export the image in the format matching its extension and repack the archive.
- Verify the file with `file background.png` (or equivalent) before packaging.
- Replace placeholder/corrupted files with real image data.
Example fix
# before: background.png is actually a JPEG mv background.jpg bg.jpg && mv bg.jpg background.jpg # use matching name # or convert: convert background.jpg background.png
Defensive patterns
Strategy: validation
Validate before calling
fn has_signature(name: &str, b: &[u8]) -> bool {
match name {
"background.png" => b.len() >= 8 && &b[..8] == b"\x89PNG\r\n\x1a\n",
"background.jpg" => b.len() >= 3 && b[..3] == [0xFF, 0xD8, 0xFF],
"background.gif" => b.len() >= 6 && (&b[..6] == b"GIF87a" || &b[..6] == b"GIF89a"),
"background.webp" => b.len() >= 12 && &b[..4] == b"RIFF" && &b[8..12] == b"WEBP",
_ => false,
}
} Try / catch
match validate_and_read_package(path, platform) {
Ok(pkg) => install(pkg),
Err(e) if e.to_string().contains("内容与扩展名不一致") => eprintln!("re-export image with matching format"),
Err(e) => return Err(e),
} Prevention
- Run `file` on images before packaging.
- Never rename images across formats without converting.
- Verify downloads are actual image bytes.
When it happens
Trigger: validate_and_read_package reads background.png/jpg/gif/webp whose content fails the signature check — e.g. a file renamed from .txt to .png, an HTML error page saved as .jpg, or a WEBP missing the RIFF/WEBP headers.
Common situations: Renaming images without converting them; download links that returned HTML; image processed by a tool that stripped headers; mistakenly packaging a placeholder file.
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
- 图片 edits 请求缺少 Content-Type
- unsupported Dream Skin image format
- 主题包必须是 32 MiB 以内的普通 ZIP 文件
- 请填写 API 的模型名称
- 官方混合 API 不应在 auth.json 中保存 OPENAI_API_KEY。请清理此供应商的…
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/cd38b3bb9f4b362f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/dream_skin_package.rs:891
.to_string();
if files.insert(normalized.clone(), content).is_some() {
bail!("主题包包含重复文件:{normalized}");
}
}
Ok(files)
}
fn validate_image_content(name: &str, bytes: &[u8]) -> anyhow::Result<()> {
let valid = match name {
"background.png" => bytes.starts_with(&[0x89, b'P', b'N', b'G', 0x0d, 0x0a, 0x1a, 0x0a]),
"background.jpg" => bytes.starts_with(&[0xff, 0xd8, 0xff]),
"background.webp" => {
bytes.len() >= 12 && &bytes[..4] == b"RIFF" && &bytes[8..12] == b"WEBP"
}
_ => false,
};
if !valid {
bail!("主题包背景图片内容与扩展名不一致:{name}");
}
Ok(())
}
fn file_limit(name: &str) -> usize {
match name {
"manifest.json" => MANIFEST_LIMIT,
"theme.json" => THEME_LIMIT,
"theme.css" => CSS_LIMIT,
"LICENSE.txt" => LICENSE_LIMIT,
"manifest.sig" => SIGNATURE_LIMIT,
_ => IMAGE_LIMIT,
}
}
fn validate_manifest(manifest: &DreamSkinPackageManifest, platform: &str) -> anyhow::Result<()> {
if manifest.package_version != 1 || manifest.skin_api_version != 1 {
bail!("不支持的 Dream Skin 主题协议版本");View on GitHub (pinned to b1ed92e5e4)