{"record":{"id":"419fdb5678687523","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-json","errorCode":null,"errorMessage":"theme.json 包含缺失或不支持的字段","messagePattern":"theme\\.json 包含缺失或不支持的字段","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":1008,"sourceCode":"        \"brandSubtitle\",\n        \"tagline\",\n        \"projectPrefix\",\n        \"projectLabel\",\n        \"statusText\",\n        \"quote\",\n        \"promoTitle\",\n        \"promoSub\",\n        \"promoUrl\",\n        \"appearance\",\n        \"art\",\n        \"colors\",\n    ];\n    if REQUIRED.iter().any(|key| !object.contains_key(*key))\n        || object\n            .keys()\n            .any(|key| !REQUIRED.contains(&key.as_str()) && !OPTIONAL.contains(&key.as_str()))\n    {\n        bail!(\"theme.json 包含缺失或不支持的字段\");\n    }\n    if object.get(\"schemaVersion\").and_then(Value::as_u64) != Some(1)\n        || object.get(\"id\").and_then(Value::as_str) != Some(manifest.theme_id.as_str())\n        || object.get(\"name\").and_then(Value::as_str).is_none()\n        || object.get(\"image\").and_then(Value::as_str) != Some(image_name)\n    {\n        bail!(\"theme.json 与 manifest 身份或背景图不一致\");\n    }\n    if object\n        .get(\"name\")\n        .and_then(Value::as_str)\n        .is_some_and(|name| !safe_manifest_text(name, 1, 80, false))\n    {\n        bail!(\"theme.json.name 无效\");\n    }\n    for key in [\n        \"brandSubtitle\",\n        \"tagline\",","sourceCodeStart":990,"sourceCodeEnd":1026,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L990-L1026","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add any missing required keys: schemaVersion, id, name, image","Delete or rename unknown keys so only whitelisted keys remain (fix e.g. \"color\" -> \"colors\")","Compare against a known-good theme.json from a working package","If extra data must ship, it needs upstream whitelist support — do not smuggle it into theme.json","Re-validate the package"],"exampleFix":"// before (theme.json)\n{\"id\": \"my-theme\", \"name\": \"My Theme\", \"image\": \"background.png\", \"colors\": {...}, \"color\": \"#fff\"}\n// after\n{\"schemaVersion\": 1, \"id\": \"my-theme\", \"name\": \"My Theme\", \"image\": \"background.png\", \"colors\": {\"color\": \"#fff\"}}","handlingStrategy":"validation","validationCode":"const REQUIRED: [&str; 4] = [\"schemaVersion\", \"id\", \"name\", \"image\"];\nconst OPTIONAL: [&str; 12] = [\"brandSubtitle\",\"tagline\",\"projectPrefix\",\"projectLabel\",\"statusText\",\"quote\",\"promoTitle\",\"promoSub\",\"promoUrl\",\"appearance\",\"art\",\"colors\"];\nfn theme_keys_ok(theme: &serde_json::Value) -> bool {\n    let Some(obj) = theme.as_object() else { return false };\n    REQUIRED.iter().all(|k| obj.contains_key(*k))\n        && obj.keys().all(|k| REQUIRED.contains(&k.as_str()) || OPTIONAL.contains(&k.as_str()))\n}\nif !theme_keys_ok(&theme) { /* fix theme.json before calling */ }","typeGuard":"fn has_whitelisted_theme_keys(theme: &serde_json::Value) -> bool {\n    theme.as_object().map_or(false, |obj| {\n        [\"schemaVersion\",\"id\",\"name\",\"image\"].iter().all(|k| obj.contains_key(*k))\n            && obj.keys().all(|k| [\"schemaVersion\",\"id\",\"name\",\"image\",\"brandSubtitle\",\"tagline\",\"projectPrefix\",\"projectLabel\",\"statusText\",\"quote\",\"promoTitle\",\"promoSub\",\"promoUrl\",\"appearance\",\"art\",\"colors\"].contains(&k.as_str()))\n    })\n}","tryCatchPattern":"match validate_and_read_package(&path, platform) {\n    Err(e) if e.to_string().contains(\"theme.json 包含缺失或不支持的字段\") => {\n        eprintln!(\"package rejected: theme.json has missing/unknown keys\");\n    }\n    other => other?,\n}","preventionTips":["Derive theme.json from a schema-validated template, never free-form editing","Run a JSON-schema check (required + additionalProperties: false) in CI","Copy keys from a known-good theme.json to avoid typos like 'color' vs 'colors'"],"tags":["theme-json","schema","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}