{"record":{"id":"405db1575c7e4359","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-css-405db1","errorCode":null,"errorMessage":"theme.css 必须至少包含一条规则","messagePattern":"theme\\.css 必须至少包含一条规则","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":387,"sourceCode":"                bail!(\"theme.css 声明数量超过限制\");\n            }\n            rule_declarations.push((property, value));\n        }\n        if rule_declarations.is_empty() {\n            bail!(\"theme.css 每条规则必须至少包含一个声明\");\n        }\n        parsed.push(SafeCssRule {\n            selector,\n            part,\n            declarations: rule_declarations,\n        });\n        if parsed.len() > 128 {\n            bail!(\"theme.css 规则数量超过限制\");\n        }\n        rest = &rest[close + 1..];\n    }\n    if parsed.is_empty() {\n        bail!(\"theme.css 必须至少包含一条规则\");\n    }\n    Ok(parsed)\n}\n\nfn forbidden_css_character(character: char) -> bool {\n    matches!(\n        character as u32,\n        0x0000..=0x0008 | 0x000b | 0x000e..=0x001f | 0x007f..=0x009f\n            | 0x2028 | 0x2029 | 0x200e | 0x200f | 0x202a..=0x202e | 0x2066..=0x2069 | 0xfeff\n    )\n}\n\nfn validate_property_value(property: &str, value: &str) -> bool {\n    const COLOR_PROPERTIES: &[&str] = &[\n        \"color\",\n        \"background-color\",\n        \"border-color\",\n        \"border-top-color\",","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L369-L405","documentation":"parse_safe_css finished scanning the stylesheet without producing any rule, so it bails instead of returning an empty Vec. A theme.css that is blank, comments-only, or whose selectors were all rejected by the safe-CSS sanitizer yields no styling at all; this forces theme packages to ship at least one parseable rule.","triggerScenarios":"Calling validate_safe_css or compile_safe_css with an empty string, whitespace-only content, or content whose rules were all rejected/never closed, so that `parsed.is_empty()` at the end of the parse loop.","commonSituations":"Packaging a theme.css placeholder that was never filled in; an editor saving a zero-byte file; a rule with unbalanced braces leaving nothing parseable.","solutions":["Add at least one valid rule, e.g. .ds-part[\"header\"] { color: #111; }.","Verify the packaged theme.css is the intended file, not an empty placeholder.","Re-export the theme after confirming the CSS compiler emitted rules."],"exampleFix":"/* before: empty theme.css */\n/* after */\n.ds-part[\"header\"] { color: #111111; }","handlingStrategy":"validation","validationCode":"fn has_at_least_one_rule(css: &str) -> bool {\n    css.contains(\"{\") && css.contains(\"}\") && !css.trim().is_empty()\n}","typeGuard":null,"tryCatchPattern":"match validate_safe_css(&css) {\n    Ok(rules) => apply(rules),\n    Err(e) if e.to_string().contains(\"必须至少包含一条规则\") => eprintln!(\"theme.css is empty; add a rule\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Never ship an empty or placeholder theme.css.","Add a CI check that theme.css contains at least one .ds-part rule.","Verify packaged files after export."],"tags":["css","validation","empty-input"],"backgroundTag":"empty-required-field","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"}