{"record":{"id":"b8c929a8f8e61ddb","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-json-colors","errorCode":null,"errorMessage":"theme.json.colors 字段无效","messagePattern":"theme\\.json\\.colors 字段无效","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":1071,"sourceCode":"    if let Some(art) = object.get(\"art\") {\n        validate_theme_art(art)?;\n    }\n    if let Some(colors) = object.get(\"colors\") {\n        let colors = colors.as_object().context(\"theme.json.colors 必须是对象\")?;\n        let keys = [\n            \"background\",\n            \"panel\",\n            \"panelAlt\",\n            \"accent\",\n            \"accentAlt\",\n            \"secondary\",\n            \"highlight\",\n            \"text\",\n            \"muted\",\n            \"line\",\n        ];\n        if colors.len() != keys.len() {\n            bail!(\"theme.json.colors 字段无效\");\n        }\n        for key in keys {\n            if colors\n                .get(key)\n                .and_then(Value::as_str)\n                .is_none_or(|value| !valid_theme_color(value))\n            {\n                bail!(\"theme.json.colors 缺少 {key}\");\n            }\n        }\n    }\n    Ok(())\n}\n\nfn validate_manifest_files(\n    manifest: &DreamSkinPackageManifest,\n    manifest_bytes: &[u8],\n    theme_bytes: &[u8],","sourceCodeStart":1053,"sourceCodeEnd":1089,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L1053-L1089","documentation":"When theme.json contains a colors object, validate_theme requires it to have exactly the 10 defined color keys (background, panel, panelAlt, accent, accentAlt, secondary, highlight, text, muted, line) — no more, no less. If colors.len() != 10 (an extra, missing, or unknown key), this error is thrown before per-key validation.","triggerScenarios":"Calling validate_and_read_package with a theme.json whose colors object has fewer than 10 keys (missing one of the required colors), more than 10 keys (added a custom color), or unknown/extra keys.","commonSituations":"Adding a custom \"card\" or \"primary\" color key; omitting a rarely used color like muted; copying an older theme format with a different color set; a typo creating a duplicate-meaning key (e.g. \"line\" vs \"lines\").","solutions":["Make colors contain exactly the 10 keys: background, panel, panelAlt, accent, accentAlt, secondary, highlight, text, muted, line","Remove any extra/custom keys not in the list","Add any missing required color keys","Fix typos in color key names"],"exampleFix":"// before\n\"colors\": { \"background\": \"#000\", \"panel\": \"#111\", \"primary\": \"#0af\" }\n// after\n\"colors\": { \"background\":\"#0d1117\", \"panel\":\"#161b22\", \"panelAlt\":\"#1c2128\", \"accent\":\"#58a6ff\", \"accentAlt\":\"#1f6feb\", \"secondary\":\"#8b949e\", \"highlight\":\"#f2cc60\", \"text\":\"#e6edf3\", \"muted\":\"#7d8590\", \"line\":\"#30363d\" }","handlingStrategy":"validation","validationCode":"const COLOR_KEYS = [\"background\",\"panel\",\"panelAlt\",\"accent\",\"accentAlt\",\"secondary\",\"highlight\",\"text\",\"muted\",\"line\"];\nif (theme.colors) {\n  const keys = Object.keys(theme.colors);\n  if (keys.length !== COLOR_KEYS.length || !COLOR_KEYS.every(k => k in theme.colors)) {\n    throw new Error(\"colors must have exactly the 10 required keys, no extras\");\n  }\n}","typeGuard":"function hasExactColorKeys(c) {\n  const REQ = [\"background\",\"panel\",\"panelAlt\",\"accent\",\"accentAlt\",\"secondary\",\"highlight\",\"text\",\"muted\",\"line\"];\n  return !!c && Object.keys(c).length === REQ.length && REQ.every(k => k in c);\n}","tryCatchPattern":null,"preventionTips":["Start every theme from the official template containing all 10 color keys","Never add custom color keys — the schema is closed","Diff your colors object against the canonical key list before packaging"],"tags":["validation","json","color-scheme","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"}