{"record":{"id":"10e4697850f86d1d","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-json-colors-key","errorCode":null,"errorMessage":"theme.json.colors 缺少 {key}","messagePattern":"theme\\.json\\.colors 缺少 (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":1079,"sourceCode":"            \"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],\n    css_bytes: &[u8],\n    image_name: &str,\n    image_bytes: &[u8],\n    license_bytes: Option<&[u8]>,\n) -> anyhow::Result<()> {\n    let mut seen = HashSet::new();\n    for file in &manifest.files {\n        if !seen.insert(file.path.as_str())","sourceCodeStart":1061,"sourceCodeEnd":1097,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L1061-L1097","documentation":"After confirming the colors object has exactly 10 keys, validate_theme checks each required color key individually: its value must be a string passing valid_theme_color. If a key is missing, is not a string, or is not a valid theme color value, this error names the offending key. The message says \"缺少\" (missing) but also covers invalid/non-string values.","triggerScenarios":"Calling validate_and_read_package with a theme.json colors object where one of the 10 keys is absent, maps to a non-string (number/object/null), or its string fails valid_theme_color (e.g. not a proper hex color).","commonSituations":"Writing colors as numbers (16777215) instead of \"#ffffff\" hex strings; using rgb() or named colors where hex is required; a typo like \"acccent\" leaving \"accent\" missing; setting a value to null.","solutions":["Add or fix the key named in the error message (e.g. \"theme.json.colors 缺少 accent\")","Use valid hex color strings for every color value","Ensure every value is a JSON string, not a number or null","Fix key-name typos so all 10 required keys exist"],"exampleFix":"// before\n\"colors\": { \"accent\": 5895055, \"muted\": null, ... }\n// after\n\"colors\": { \"accent\": \"#58a6ff\", \"muted\": \"#7d8590\", ... }","handlingStrategy":"validation","validationCode":"const HEX = /^#[0-9a-fA-F]{3,8}$/;\nfor (const [k, v] of Object.entries(theme.colors ?? {})) {\n  if (typeof v !== \"string\" || !HEX.test(v)) {\n    throw new Error(`colors.${k} must be a valid hex color string`);\n  }\n}","typeGuard":"function isValidThemeColor(v) {\n  return typeof v === \"string\" && /^#[0-9a-fA-F]{3,8}$/.test(v);\n}","tryCatchPattern":null,"preventionTips":["Use a color picker that emits hex strings, not numbers or named colors","Add per-key JSON-schema validation for colors in CI","Quote all color values in theme.json"],"tags":["validation","json","color-format","skin-package"],"backgroundTag":"invalid-argument-format","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"}