{"record":{"id":"92b976b8289ef4d8","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-json-key","errorCode":null,"errorMessage":"theme.json.{key} 无效","messagePattern":"theme\\.json\\.(.+?) 无效","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":1039,"sourceCode":"    {\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    ] {\n        if object.get(key).is_some_and(|value| {\n            value\n                .as_str()\n                .is_none_or(|text| !safe_manifest_text(text, 0, 120, false))\n        }) {\n            bail!(\"theme.json.{key} 无效\");\n        }\n    }\n    if object.get(\"promoUrl\").is_some_and(|value| {\n        value\n            .as_str()\n            .is_none_or(|text| !safe_manifest_text(text, 0, 512, false))\n    }) || object.get(\"appearance\").is_some_and(|value| {\n        value\n            .as_str()\n            .is_none_or(|appearance| !matches!(appearance, \"auto\" | \"light\" | \"dark\"))\n    }) {\n        bail!(\"theme.json 的链接或外观字段无效\");\n    }\n    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 必须是对象\")?;","sourceCodeStart":1021,"sourceCodeEnd":1057,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L1021-L1057","documentation":"validate_theme checks each optional text field (brandSubtitle, tagline, projectPrefix, projectLabel, statusText, quote, promoTitle, promoSub) of theme.json. If a field is present but is not a string, or its string fails safe_manifest_text(text, 0, 120, false) (over 120 chars or unsafe characters), the library bails with the offending key in the message.","triggerScenarios":"Calling validate_and_read_package with a theme.json where any of the eight optional text keys is present as a non-string (number, null is absent-safe, object) or as a string longer than 120 chars / containing unsafe characters.","commonSituations":"Putting a number or boolean in projectPrefix; pasting a tagline over 120 characters; embedding newlines or control characters in statusText or quote; using localized text with forbidden characters.","solutions":["Make the offending field a plain string (check the key named in the message)","Shorten the string to 120 characters or fewer","Remove control characters, newlines, and other unsafe content","Omit the field entirely if not needed — all eight keys are optional"],"exampleFix":"// before\n\"tagline\": 42\n// after\n\"tagline\": \"Ship faster with a dark theme\"","handlingStrategy":"validation","validationCode":"const TEXT_KEYS = [\"brandSubtitle\",\"tagline\",\"projectPrefix\",\"projectLabel\",\"statusText\",\"quote\",\"promoTitle\",\"promoSub\"];\nfor (const k of TEXT_KEYS) {\n  if (k in theme && (typeof theme[k] !== \"string\" || theme[k].length > 120 || /[\\u0000-\\u001f]/.test(theme[k]))) {\n    throw new Error(`theme.json.${k} must be a safe string of at most 120 chars`);\n  }\n}","typeGuard":"function isValidOptionalText(v) {\n  return typeof v === \"string\" && v.length <= 120 && !/[\\u0000-\\u001f]/.test(v);\n}","tryCatchPattern":null,"preventionTips":["Omit optional text fields you do not need instead of writing empty/placeholder values","Enforce a 120-char limit in your theme authoring UI","Sanitize pasted marketing copy (newlines, control chars) before insertion"],"tags":["validation","json","text-length","skin-package"],"backgroundTag":"invalid-argument-value","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"}