{"record":{"id":"e25c787ffdcdb727","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-json-art-key","errorCode":null,"errorMessage":"theme.json.art.{key} 无效","messagePattern":"theme\\.json\\.art\\.(.+?) 无效","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":1294,"sourceCode":"    rest[1..3].parse::<u32>().is_ok_and(|hour| hour <= 23)\n        && rest[4..6].parse::<u32>().is_ok_and(|minute| minute <= 59)\n}\n\nfn validate_theme_art(value: &Value) -> anyhow::Result<()> {\n    let object = value.as_object().context(\"theme.json.art 必须是对象\")?;\n    if object\n        .keys()\n        .any(|key| !matches!(key.as_str(), \"focusX\" | \"focusY\" | \"safeArea\" | \"taskMode\"))\n    {\n        bail!(\"theme.json.art 包含不支持的字段\");\n    }\n    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('#') {","sourceCodeStart":1276,"sourceCodeEnd":1312,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L1276-L1312","documentation":"validate_theme_art validates the numeric fields focusX and focusY inside theme.json.art. Both must parse as finite f64 values within the inclusive range 0.0..=1.0 (normalized focal-point coordinates). The library throws \"theme.json.art.{key} 无效\" when either key is present but its value is not a finite number in [0,1].","triggerScenarios":"Calling validate_theme where theme.json.art.focusX or theme.json.art.focusY is: a string (\"0.5\"), null, boolean, an object/array, NaN/infinite after parsing, or a number outside [0.0, 1.0] such as 1.5 or -0.1.","commonSituations":"Authors writing pixel coordinates (e.g. 512) instead of normalized 0-1 values; exporting focus points from design tools as percentages (50 instead of 0.5); quoting the number in JSON; negative or >1 values from manual editing.","solutions":["Open theme.json and locate art.focusX / art.focusY.","Convert pixel or percentage coordinates to normalized values: value = pixel / imageDimension (or percent / 100).","Ensure the value is an unquoted JSON number between 0.0 and 1.0 inclusive.","Remove quotes around the number if it is a string, and remove null/objects from these keys.","Re-validate the package to confirm."],"exampleFix":"// before: pixel coordinate and quoted value\n{ \"art\": { \"focusX\": \"0.75\", \"focusY\": 512 } }\n// after: normalized numbers in [0,1]\n{ \"art\": { \"focusX\": 0.75, \"focusY\": 0.5 } }","handlingStrategy":"validation","validationCode":"fn focus_valid(v: Option<&Value>) -> bool {\n    v.map(|v| v.as_f64().map_or(false, |n| n.is_finite() && (0.0..=1.0).contains(&n))).unwrap_or(true)\n}\n// art.focusX/focusY must pass focus_valid","typeGuard":"fn is_unit_f64(v: &Value) -> bool {\n    v.as_f64().map_or(false, |n| n.is_finite() && (0.0..=1.0).contains(&n))\n}","tryCatchPattern":"match validate_theme(value) {\n    Err(e) if e.to_string().contains(\"art.focus\") => eprintln!(\"focusX/focusY must be finite numbers in [0,1]: {e}\"),\n    other => other?,\n}","preventionTips":["Always export focus points as normalized 0-1 values, not pixels or percentages.","Never quote focusX/focusY values in JSON.","Add a linter on theme.json that checks numeric ranges before packaging."],"tags":["skin-package","theme-json","range-validation"],"backgroundTag":"value-out-of-range","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"}