{"record":{"id":"3037873c6f4bdd74","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-json-name","errorCode":null,"errorMessage":"theme.json.name 无效","messagePattern":"theme\\.json\\.name 无效","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":1022,"sourceCode":"        || 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    ] {\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        }","sourceCodeStart":1004,"sourceCodeEnd":1040,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L1004-L1040","documentation":"validate_theme rejects theme.json when the name field, though present and a string, fails safe_manifest_text(name, 1, 80, false) — i.e. it is empty, longer than 80 characters, or contains disallowed characters (e.g. control characters or newlines). The library enforces display-text hygiene to keep theme names safe to render.","triggerScenarios":"Calling validate_and_read_package with a theme.json whose name is an empty string, exceeds 80 characters, or contains characters rejected by safe_manifest_text (control chars, newlines, etc.).","commonSituations":"Leaving name as \"\" in a template; pasting a long title with a trailing newline; including emoji/control characters or HTML in the theme name; copying a name over 80 chars from a marketing document.","solutions":["Set theme.json.name to a non-empty string of at most 80 characters","Strip control characters, newlines, and other unsafe text from name","Trim whitespace so the name is not effectively empty","Re-run validation after editing to confirm the value passes"],"exampleFix":"// before\n\"name\": \"\"  // or a 200-char name\n// after\n\"name\": \"Midnight codex\"","handlingStrategy":"validation","validationCode":"const name = theme.name;\nif (typeof name !== \"string\" || name.trim().length === 0 || name.length > 80 || /[\\u0000-\\u001f]/.test(name)) {\n  throw new Error(\"theme.json.name must be 1-80 safe characters\");\n}","typeGuard":"function isValidThemeName(v) {\n  return typeof v === \"string\" && v.length >= 1 && v.length <= 80 &&\n    !/[\\u0000-\\u001f]/.test(v);\n}","tryCatchPattern":null,"preventionTips":["Keep theme names under 80 characters, trimmed","Strip control characters and newlines before writing theme.json","Validate name in CI before packaging"],"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"}