BigPizzaV3/CodexPlusPlus · error

manifest.files 的 mediaType 不匹配:

Error message

manifest.files 的 mediaType 不匹配:{}

What it means

For each manifest.files entry, validate_manifest_files derives the expected media type from the file path (theme.json -> application/json, theme.css -> text/css, background.webp/jpg/png -> image/webp|jpeg|png, LICENSE.txt -> text/plain) and requires the declared mediaType to match exactly. A mismatch throws this error naming the file.

Solutions

  1. Set each entry's mediaType to the value implied by its path (theme.json: application/json; theme.css: text/css; background.webp: image/webp; background.jpg: image/jpeg; background.png: image/png; LICENSE.txt: text/plain)
  2. Update mediaType whenever you rename or swap the background image extension
  3. Regenerate the manifest with the packaging tool so media types are computed automatically

Example fix

// before
{ "path": "background.jpg", "mediaType": "image/png", ... }
// after
{ "path": "background.jpg", "mediaType": "image/jpeg", ... }
Defensive patterns

Strategy: validation

Validate before calling

const MIME = { "theme.json":"application/json", "theme.css":"text/css", "background.webp":"image/webp", "background.jpg":"image/jpeg", "background.png":"image/png", "LICENSE.txt":"text/plain" };
for (const f of manifest.files) {
  if (f.path in MIME && f.mediaType !== MIME[f.path]) {
    throw new Error(`${f.path}: mediaType must be ${MIME[f.path]}`);
  }
}

Type guard

function hasMatchingMediaType(f) {
  const MIME = { "theme.json":"application/json", "theme.css":"text/css", "background.webp":"image/webp", "background.jpg":"image/jpeg", "background.png":"image/png", "LICENSE.txt":"text/plain" };
  return !(f.path in MIME) || f.mediaType === MIME[f.path];
}

Prevention

When it happens

Trigger: Calling validate_and_read_package where a files entry declares a mediaType that does not equal the value derived from its path — e.g. theme.css declared as application/json, background.jpg declared as image/png, or a wrong/missing/extra mediaType on any entry.

Common situations: Hand-editing mediaType fields; using generic application/octet-stream for images; switching the background from .jpg to .png without updating mediaType; copying entries between files without adjusting the type.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

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

            "manifest.json" => manifest_bytes,
            "theme.json" => theme_bytes,
            "theme.css" => css_bytes,
            path if path == image_name => image_bytes,
            "LICENSE.txt" => license_bytes.context("manifest 声明了 LICENSE.txt 但包内缺失")?,
            "manifest.sig" => continue,
            _ => continue,
        };
        let expected_media_type = match file.path.as_str() {
            "theme.json" => "application/json",
            "theme.css" => "text/css",
            "background.webp" => "image/webp",
            "background.jpg" => "image/jpeg",
            "background.png" => "image/png",
            "LICENSE.txt" => "text/plain",
            _ => "",
        };
        if file.media_type != expected_media_type {
            bail!("manifest.files 的 mediaType 不匹配:{}", file.path);
        }
        let actual = format!("{:x}", Sha256::digest(bytes));
        if file.bytes != bytes.len() || !actual.eq_ignore_ascii_case(&file.sha256) {
            bail!("manifest.files 的 SHA-256 或大小不匹配:{}", file.path);
        }
    }
    if !seen.contains("theme.json") || !seen.contains("theme.css") || !seen.contains(image_name) {
        bail!("manifest.files 缺少必需文件");
    }
    if seen.contains("LICENSE.txt") != license_bytes.is_some() {
        bail!("manifest.files 的 LICENSE.txt 与包内容不一致");
    }
    Ok(())
}

fn valid_theme_id(value: &str) -> bool {
    let mut chars = value.chars();
    chars.next().is_some_and(|c| c.is_ascii_alphanumeric())

View on GitHub (pinned to b1ed92e5e4)