BigPizzaV3/CodexPlusPlus · error

theme.css CSS 属性无效或重复:

Error message

theme.css CSS 属性无效或重复:{property}

What it means

Within each rule, declarations are split on ';' and each must have a property name consisting solely of ASCII lowercase letters (with '-' allowed after the first byte) that has not already appeared in the same rule. Uppercase, digits, leading hyphens, unknown identifiers or duplicate properties bail with 'theme.css CSS 属性无效或重复:{property}'.

Solutions

  1. Keep one declaration per property per rule; delete the duplicate occurrence
  2. Lowercase all property names and remove vendor prefixes (`-webkit-backdrop-filter` → `backdrop-filter`)
  3. Restrict properties to the Safe CSS whitelist (color/background-color/border-*/gap/box-shadow/opacity/backdrop-filter/font-*/line-height/letter-spacing/transition-*)

Example fix

// before
[data-ds-part="main"] { color: #fff; Color: #000; color: #eee; }
// after
[data-ds-part="main"] { color: #eeeeee; }
Defensive patterns

Strategy: validation

Validate before calling

fn property_ok(prop: &str) -> bool {
    !prop.is_empty()
        && prop.bytes().enumerate().all(|(i, b)| b.is_ascii_lowercase() || (i > 0 && b == b'-'))
}
fn rule_has_no_duplicate_props(decls: &[(&str, &str)]) -> bool {
    let mut seen = std::collections::HashSet::new();
    decls.iter().all(|(p, _)| seen.insert(*p))
}

Try / catch

match validate_safe_css(&css) {
    Err(e) if e.to_string().contains("属性无效或重复") => Err("lowercase properties, drop vendor prefixes and duplicates".into()),
    other => other,
}

Prevention

When it happens

Trigger: Vendor-prefixed or camelCase properties (`-webkit-backdrop-filter` rejected due to leading '-', `backgroundColor`); properties with digits (`h1`-style names); writing the same property twice in one rule (`color: #fff; color: #000;`); empty property before ':' or whitespace embedded in the name.

Common situations: Copy-pasted CSS containing browser prefixes; authors repeating a property to 'override' earlier values as in plain CSS; auto-generated CSS with uppercase or custom properties (--vars are only allowed on the value side for whitelisted ones).

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/7ca94d354f2a5675. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/dream_skin_package.rs:358

        let mut rule_declarations = Vec::new();
        let mut seen = HashSet::new();
        for declaration in rest[open + 1..close]
            .split(';')
            .map(str::trim)
            .filter(|value| !value.is_empty())
        {
            let (property, value) = declaration
                .split_once(':')
                .context("theme.css 声明语法无效")?;
            let property = property.trim();
            let value = value.trim();
            if !property
                .bytes()
                .enumerate()
                .all(|(index, byte)| byte.is_ascii_lowercase() || (index > 0 && byte == b'-'))
                || !seen.insert(property)
            {
                bail!("theme.css CSS 属性无效或重复:{property}");
            }
            if value.is_empty()
                || value.chars().count() > 512
                || value.contains(['{', '}', '<', '>', '!', ';'])
                || !validate_property_value(property, value)
            {
                bail!("theme.css 属性值不受 Safe CSS 支持:{property}");
            }
            declarations += 1;
            if declarations > 512 {
                bail!("theme.css 声明数量超过限制");
            }
            rule_declarations.push((property, value));
        }
        if rule_declarations.is_empty() {
            bail!("theme.css 每条规则必须至少包含一个声明");
        }
        parsed.push(SafeCssRule {

View on GitHub (pinned to b1ed92e5e4)