{"record":{"id":"6a2cfd0bb5f1fe0b","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-json-art-6a2cfd","errorCode":null,"errorMessage":"theme.json.art 枚举值无效","messagePattern":"theme\\.json\\.art 枚举值无效","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":1306,"sourceCode":"    for key in [\"focusX\", \"focusY\"] {\n        if object.get(key).is_some_and(|value| {\n            value\n                .as_f64()\n                .is_none_or(|number| !number.is_finite() || !(0.0..=1.0).contains(&number))\n        }) {\n            bail!(\"theme.json.art.{key} 无效\");\n        }\n    }\n    if object.get(\"safeArea\").is_some_and(|value| {\n        value\n            .as_str()\n            .is_none_or(|value| !matches!(value, \"left\" | \"right\" | \"none\"))\n    }) || object.get(\"taskMode\").is_some_and(|value| {\n        value\n            .as_str()\n            .is_none_or(|value| !matches!(value, \"ambient\" | \"full\" | \"off\"))\n    }) {\n        bail!(\"theme.json.art 枚举值无效\");\n    }\n    Ok(())\n}\n\nfn valid_theme_color(value: &str) -> bool {\n    if let Some(hex) = value.strip_prefix('#') {\n        return matches!(hex.len(), 3 | 4 | 6 | 8)\n            && hex.bytes().all(|byte| byte.is_ascii_hexdigit());\n    }\n    if value.starts_with(\"rgb(\") && value.ends_with(')') {\n        let values = &value[4..value.len() - 1];\n        return split_top_level(values, ',').is_some_and(|values| {\n            values.len() == 3\n                && values.into_iter().all(|value| {\n                    let value = value.trim();\n                    !value.is_empty()\n                        && value.len() <= 3\n                        && value.bytes().all(|byte| byte.is_ascii_digit())","sourceCodeStart":1288,"sourceCodeEnd":1324,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L1288-L1324","documentation":"validate_theme_art enforces the allowed enum strings for theme.json.art.safeArea and theme.json.art.taskMode. safeArea must be one of \"left\" | \"right\" | \"none\"; taskMode must be one of \"ambient\" | \"full\" | \"off\". The library throws this error when either key is present with any other (or non-string) value.","triggerScenarios":"Calling validate_theme where theme.json.art.safeArea is not exactly \"left\"/\"right\"/\"none\" (e.g. \"top\", \"Left\", 1), or theme.json.art.taskMode is not exactly \"ambient\"/\"full\"/\"off\" (e.g. \"auto\", true).","commonSituations":"Case mismatches (\"Left\"); inventing values not in the spec (\"top\", \"center\"); using numbers/booleans instead of strings; copying values from a different skin format with different enums.","solutions":["Open theme.json and check art.safeArea and art.taskMode values.","Set safeArea to exactly \"left\", \"right\", or \"none\".","Set taskMode to exactly \"ambient\", \"full\", or \"off\".","Fix case and remove quotes issues: values are lowercase strings.","Re-validate the theme."],"exampleFix":"// before\n{ \"art\": { \"safeArea\": \"Top\", \"taskMode\": \"auto\" } }\n// after\n{ \"art\": { \"safeArea\": \"none\", \"taskMode\": \"ambient\" } }","handlingStrategy":"validation","validationCode":"fn art_enums_valid(art: &Value) -> bool {\n    let safe = art.get(\"safeArea\").and_then(|v| v.as_str()).map_or(true, |s| matches!(s, \"left\"|\"right\"|\"none\"));\n    let task = art.get(\"taskMode\").and_then(|v| v.as_str()).map_or(true, |s| matches!(s, \"ambient\"|\"full\"|\"off\"));\n    safe && task\n}","typeGuard":"fn is_valid_safe_area(v: &Value) -> bool {\n    matches!(v.as_str(), Some(\"left\") | Some(\"right\") | Some(\"none\"))\n}","tryCatchPattern":"match validate_theme(value) {\n    Err(e) if e.to_string().contains(\"枚举值无效\") => eprintln!(\"art.safeArea/taskMode must use allowed enum strings: {e}\"),\n    other => other?,\n}","preventionTips":["Use enum-typed constants when generating theme.json (SafeArea::{Left,Right,None}, TaskMode::{Ambient,Full,Off}).","Keep enum values lowercase exactly as specified.","Validate enums in the editor UI before export."],"tags":["skin-package","theme-json","enum-validation"],"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"}