BigPizzaV3/CodexPlusPlus · error

theme.json 包含缺失或不支持的字段

Error message

theme.json 包含缺失或不支持的字段

What it means

validate_theme rejects theme.json when any required key (schemaVersion, id, name, image) is missing or when the object contains keys outside the REQUIRED + OPTIONAL whitelist (brandSubtitle, tagline, projectPrefix, projectLabel, statusText, quote, promoTitle, promoSub, promoUrl, appearance, art, colors). The schema is closed: unknown fields are treated as incompatible or tampered content. Thrown from validate_and_read_package.

Solutions

  1. Add any missing required keys: schemaVersion, id, name, image
  2. Delete or rename unknown keys so only whitelisted keys remain (fix e.g. "color" -> "colors")
  3. Compare against a known-good theme.json from a working package
  4. If extra data must ship, it needs upstream whitelist support — do not smuggle it into theme.json
  5. Re-validate the package

Example fix

// before (theme.json)
{"id": "my-theme", "name": "My Theme", "image": "background.png", "colors": {...}, "color": "#fff"}
// after
{"schemaVersion": 1, "id": "my-theme", "name": "My Theme", "image": "background.png", "colors": {"color": "#fff"}}
Defensive patterns

Strategy: validation

Validate before calling

const REQUIRED: [&str; 4] = ["schemaVersion", "id", "name", "image"];
const OPTIONAL: [&str; 12] = ["brandSubtitle","tagline","projectPrefix","projectLabel","statusText","quote","promoTitle","promoSub","promoUrl","appearance","art","colors"];
fn theme_keys_ok(theme: &serde_json::Value) -> bool {
    let Some(obj) = theme.as_object() else { return false };
    REQUIRED.iter().all(|k| obj.contains_key(*k))
        && obj.keys().all(|k| REQUIRED.contains(&k.as_str()) || OPTIONAL.contains(&k.as_str()))
}
if !theme_keys_ok(&theme) { /* fix theme.json before calling */ }

Type guard

fn has_whitelisted_theme_keys(theme: &serde_json::Value) -> bool {
    theme.as_object().map_or(false, |obj| {
        ["schemaVersion","id","name","image"].iter().all(|k| obj.contains_key(*k))
            && obj.keys().all(|k| ["schemaVersion","id","name","image","brandSubtitle","tagline","projectPrefix","projectLabel","statusText","quote","promoTitle","promoSub","promoUrl","appearance","art","colors"].contains(&k.as_str()))
    })
}

Try / catch

match validate_and_read_package(&path, platform) {
    Err(e) if e.to_string().contains("theme.json 包含缺失或不支持的字段") => {
        eprintln!("package rejected: theme.json has missing/unknown keys");
    }
    other => other?,
}

Prevention

When it happens

Trigger: validate_and_read_package parses theme.json that omits one of the four required keys, or includes a typo'd/extra key such as "color" instead of "colors", "Title" instead of "title", or custom fields added by another tool.

Common situations: Hand-editing theme.json and misspelling keys; themes exported by newer/other tooling with extra fields; copy-paste adding duplicate-purpose keys; camelCase vs snake_case mistakes.

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/419fdb5678687523. Report an issue: GitHub.

Appendix: source

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

        "brandSubtitle",
        "tagline",
        "projectPrefix",
        "projectLabel",
        "statusText",
        "quote",
        "promoTitle",
        "promoSub",
        "promoUrl",
        "appearance",
        "art",
        "colors",
    ];
    if REQUIRED.iter().any(|key| !object.contains_key(*key))
        || object
            .keys()
            .any(|key| !REQUIRED.contains(&key.as_str()) && !OPTIONAL.contains(&key.as_str()))
    {
        bail!("theme.json 包含缺失或不支持的字段");
    }
    if object.get("schemaVersion").and_then(Value::as_u64) != Some(1)
        || object.get("id").and_then(Value::as_str) != Some(manifest.theme_id.as_str())
        || object.get("name").and_then(Value::as_str).is_none()
        || object.get("image").and_then(Value::as_str) != Some(image_name)
    {
        bail!("theme.json 与 manifest 身份或背景图不一致");
    }
    if object
        .get("name")
        .and_then(Value::as_str)
        .is_some_and(|name| !safe_manifest_text(name, 1, 80, false))
    {
        bail!("theme.json.name 无效");
    }
    for key in [
        "brandSubtitle",
        "tagline",

View on GitHub (pinned to b1ed92e5e4)