{"record":{"id":"85841a3b88809dfa","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-css-85841a","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":374,"sourceCode":"                || !seen.insert(property)\n            {\n                bail!(\"theme.css CSS 属性无效或重复：{property}\");\n            }\n            if value.is_empty()\n                || value.chars().count() > 512\n                || value.contains(['{', '}', '<', '>', '!', ';'])\n                || !validate_property_value(property, value)\n            {\n                bail!(\"theme.css 属性值不受 Safe CSS 支持：{property}\");\n            }\n            declarations += 1;\n            if declarations > 512 {\n                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 {","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L356-L392","documentation":"After parsing a rule's declarations, parse_safe_css requires at least one non-empty `property: value;` declaration inside the braces; a rule like `[data-ds-part=\"main\"] { }` (or containing only empty fragments between semicolons) bails with 'theme.css 每条规则必须至少包含一个声明'. Empty rules add nothing to the cascade and are treated as malformed input.","triggerScenarios":"Selector blocks with empty or whitespace-only bodies; bodies containing only stray semicolons (split(';') filters empty fragments); CSS where all declarations were stripped during sanitization (e.g. comments removed leaving nothing).","commonSituations":"Authors leaving placeholder rules while iterating on a theme; tools that minify out declarations but keep the selector; copy-paste errors leaving `{ }` stubs.","solutions":["Delete every rule whose braces contain no declaration","If a rule lost its declarations during sanitization/cleanup, restore at least one valid whitelisted declaration or remove the selector entirely","Validate locally with validate_safe_css before packaging to catch stub rules early"],"exampleFix":"// before\n[data-ds-part=\"header\"] { }\n// after\n[data-ds-part=\"header\"] { background-color: var(--ds-theme-color-panel); }","handlingStrategy":"validation","validationCode":"fn no_empty_rules(css: &str) -> bool {\n    css.split('{').skip(1).filter_map(|rest| rest.split('}').next()).all(|body| !body.is_empty() && body.split(';').any(|d| !d.trim().is_empty()))\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = validate_safe_css(&css) {\n    if e.to_string().contains(\"至少包含一个声明\") {\n        return Err(\"remove rules with empty bodies\".into());\n    }\n    return Err(e.into());\n}","preventionTips":["Delete placeholder rules with empty `{ }` bodies before packaging","After stripping comments/invalid declarations, re-check that each remaining rule still has content","Run validate_safe_css as part of the packaging pipeline to catch stub rules"],"tags":["css","empty-rule","validation"],"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"}