{"record":{"id":"9620df49a2a212d2","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-json-manifest","errorCode":null,"errorMessage":"theme.json 与 manifest 身份或背景图不一致","messagePattern":"theme\\.json 与 manifest 身份或背景图不一致","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":1015,"sourceCode":"        \"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\",\n        \"projectPrefix\",\n        \"projectLabel\",\n        \"statusText\",\n        \"quote\",\n        \"promoTitle\",\n        \"promoSub\",\n    ] {","sourceCodeStart":997,"sourceCodeEnd":1033,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L997-L1033","documentation":"validate_theme rejects a theme.json whose identity fields do not agree with the package manifest and the bundled image. The library requires schemaVersion==1, theme.json id equal to manifest.theme_id, a string name, and an image field exactly matching the background image filename declared in the manifest. This cross-file consistency check prevents packages that claim one identity in manifest.json but ship a different one in theme.json.","triggerScenarios":"Calling validate_and_read_package on a skin package where theme.json has schemaVersion != 1 (or non-numeric), theme.json.id differs from manifest.theme_id, theme.json.name is not a string, or theme.json.image differs from the manifest's background image filename.","commonSituations":"Hand-editing theme.json and renaming the background file only in one file; regenerating a manifest with a new theme_id while reusing an old theme.json; writing schemaVersion as a string \"1\" instead of the number 1; pointing image at a different resolution file than the one listed in manifest.files.","solutions":["Set theme.json schemaVersion to the number 1 (not the string \"1\")","Make theme.json.id exactly equal to manifest.json's themeId field","Set theme.json.image to the exact background image filename (e.g. \"background.webp\") used in manifest.files","Ensure theme.json.name is a plain string value","Regenerate both manifest.json and theme.json together with the packaging tool instead of editing one"],"exampleFix":"// before (theme.json)\n{ \"schemaVersion\": \"1\", \"id\": \"old-theme\", \"image\": \"background.png\", ... }\n// after\n{ \"schemaVersion\": 1, \"id\": \"my-theme\", \"name\": \"My Theme\", \"image\": \"background.webp\", ... }","handlingStrategy":"validation","validationCode":"const t = JSON.parse(themeJson);\nconst m = JSON.parse(manifestJson);\nif (t.schemaVersion !== 1) throw new Error(\"schemaVersion must be number 1\");\nif (t.id !== m.themeId) throw new Error(\"theme.json id != manifest themeId\");\nif (typeof t.name !== \"string\") throw new Error(\"name must be string\");\nif (t.image !== m.image) throw new Error(\"theme.json image != manifest image\");","typeGuard":"function hasConsistentIdentity(t, m) {\n  return typeof t === \"object\" && t !== null &&\n    t.schemaVersion === 1 && t.id === m.themeId &&\n    typeof t.name === \"string\" && t.image === m.image;\n}","tryCatchPattern":null,"preventionTips":["Always generate theme.json and manifest.json together from one source of truth","Keep themeId and image filename in shared constants used by both files","Never hand-edit one of the two files in isolation","Write schemaVersion as a JSON number"],"tags":["validation","json","schema-mismatch","skin-package"],"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"}