BigPizzaV3/CodexPlusPlus · error
theme.css 必须至少包含一条规则
Error message
theme.css 必须至少包含一条规则
What it means
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.
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.
Example fix
/* before: empty theme.css */
/* after */
.ds-part["header"] { color: #111111; } Defensive patterns
Strategy: validation
Validate before calling
fn has_at_least_one_rule(css: &str) -> bool {
css.contains("{") && css.contains("}") && !css.trim().is_empty()
} Try / catch
match validate_safe_css(&css) {
Ok(rules) => apply(rules),
Err(e) if e.to_string().contains("必须至少包含一条规则") => eprintln!("theme.css is empty; add a rule"),
Err(e) => return Err(e),
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- 请先粘贴 MCP 配置 JSON
- theme.css 规则数量超过限制
- theme.css 每条规则必须至少包含一个声明
- theme.css CSS 属性无效或重复:
- 主题包必须是 32 MiB 以内的普通 ZIP 文件
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/405db1575c7e4359.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/dream_skin_package.rs:387
bail!("theme.css 声明数量超过限制");
}
rule_declarations.push((property, value));
}
if rule_declarations.is_empty() {
bail!("theme.css 每条规则必须至少包含一个声明");
}
parsed.push(SafeCssRule {
selector,
part,
declarations: rule_declarations,
});
if parsed.len() > 128 {
bail!("theme.css 规则数量超过限制");
}
rest = &rest[close + 1..];
}
if parsed.is_empty() {
bail!("theme.css 必须至少包含一条规则");
}
Ok(parsed)
}
fn forbidden_css_character(character: char) -> bool {
matches!(
character as u32,
0x0000..=0x0008 | 0x000b | 0x000e..=0x001f | 0x007f..=0x009f
| 0x2028 | 0x2029 | 0x200e | 0x200f | 0x202a..=0x202e | 0x2066..=0x2069 | 0xfeff
)
}
fn validate_property_value(property: &str, value: &str) -> bool {
const COLOR_PROPERTIES: &[&str] = &[
"color",
"background-color",
"border-color",
"border-top-color",View on GitHub (pinned to b1ed92e5e4)