{"record":{"id":"9c06ebb8f3748d25","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-json-9c06eb","errorCode":null,"errorMessage":"theme.json 的链接或外观字段无效","messagePattern":"theme\\.json 的链接或外观字段无效","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":1051,"sourceCode":"    ] {\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 必须是对象\")?;\n        let keys = [\n            \"background\",\n            \"panel\",\n            \"panelAlt\",\n            \"accent\",\n            \"accentAlt\",\n            \"secondary\",\n            \"highlight\",\n            \"text\",\n            \"muted\",\n            \"line\",\n        ];","sourceCodeStart":1033,"sourceCodeEnd":1069,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L1033-L1069","documentation":"validate_theme validates two special optional fields together: promoUrl must be a safe string of at most 512 characters, and appearance must be exactly one of \"auto\", \"light\", or \"dark\". If either present field fails these constraints, the library throws this combined error.","triggerScenarios":"Calling validate_and_read_package with a theme.json where promoUrl is a non-string or exceeds 512 chars / unsafe text, or appearance is a string other than auto/light/dark (or a non-string).","commonSituations":"Typing \"system\" or \"default\" for appearance instead of \"auto\"; putting an overly long tracking URL in promoUrl; localizing appearance values (e.g. \"自动\"); quoting appearance as a number.","solutions":["Set appearance to exactly \"auto\", \"light\", or \"dark\"","Shorten promoUrl to 512 characters or fewer and remove unsafe characters","Ensure both values are plain JSON strings","Omit either field if not needed — both are optional"],"exampleFix":"// before\n\"appearance\": \"system\",\n\"promoUrl\": 123\n// after\n\"appearance\": \"auto\",\n\"promoUrl\": \"https://example.com/promo\"","handlingStrategy":"validation","validationCode":"if (\"appearance\" in theme && ![\"auto\",\"light\",\"dark\"].includes(theme.appearance)) {\n  throw new Error(\"appearance must be auto|light|dark\");\n}\nif (\"promoUrl\" in theme && (typeof theme.promoUrl !== \"string\" || theme.promoUrl.length > 512 || /[\\u0000-\\u001f]/.test(theme.promoUrl))) {\n  throw new Error(\"promoUrl must be a safe string of at most 512 chars\");\n}","typeGuard":"function isAppearance(v) {\n  return v === \"auto\" || v === \"light\" || v === \"dark\";\n}","tryCatchPattern":null,"preventionTips":["Use a dropdown/enum for appearance (auto|light|dark) in tooling, never free text","Keep promo URLs short; strip tracking parameters if the URL grows past 512 chars","Validate the theme JSON schema in CI before packaging"],"tags":["validation","json","enum-value","skin-package"],"backgroundTag":"invalid-enum-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"}