BigPizzaV3/CodexPlusPlus · error

invalid Dream Skin theme color

Error message

invalid Dream Skin theme color: {color}

What it means

validate_theme_draft iterates every color in draft.config.colors (background, panel, panel_alt, highlight, text, muted, line) and requires each to pass valid_css_color: a hex color (#RGB, #RGBA, #RRGGBB, #RRGGBBAA) or an rgb()/rgba() expression containing only digits, whitespace, commas, dots and percent signs. Any other string (named colors, hsl(), 'transparent', CSS variables) is rejected with the offending value in the message.

Solutions

  1. Convert colors to #RRGGBB (or #RRGGBBAA / #RGB / #RGBA) hex form before assigning to config.colors.
  2. Convert rgb()/rgba() values to the digit/comma form the validator accepts, e.g. "rgb(24, 32, 48)".
  3. Resolve CSS variables and named colors at generation time in your UI (color picker output) rather than storing them raw.
  4. Pre-validate each color with the same hex/rgb grammar in your form before constructing the draft.

Example fix

// before
config.colors = Some(Colors { background: "var(--bg)".into(), .. });
save_dream_skin_theme(&state_dir, &draft(config))?;
// after
config.colors = Some(Colors { background: "#101820".into(), .. }); // hex always passes
save_dream_skin_theme(&state_dir, &draft(config))?;
Defensive patterns

Strategy: validation

Validate before calling

fn valid_css_color(value: &str) -> bool {
    let v = value.trim();
    if let Some(h) = v.strip_prefix('#') {
        return matches!(h.len(), 3 | 4 | 6 | 8) && h.bytes().all(|b| b.is_ascii_hexdigit());
    }
    v.strip_prefix("rgb(").or_else(|| v.strip_prefix("rgba("))
        .and_then(|b| b.strip_suffix(')'))
        .map_or(false, |b| !b.is_empty() && b.bytes().all(|b| b.is_ascii_digit() || b.is_ascii_whitespace() || matches!(b, b',' | b'.' | b'%')))
}

Try / catch

for (k, v) in all_colors(&config) {
    if !valid_css_color(&v) { return Err(anyhow!("field {k} must be hex or rgb(), got {v}")); }
}

Prevention

When it happens

Trigger: Saving/activating a theme whose colors contain a non-hex, non-rgb() string such as "red", "hsl(0 100% 50%)", "var(--bg)", "#12345" (bad hex length), "rgb(300, 0, 0)" is fine format-wise but "#GGHHII" or "transparent" fail.

Common situations: Picking colors from a CSS design system that uses named colors or CSS variables; importing themes written for a web context that allows the full CSS color grammar; hand-editing theme.json with a typo in a hex triplet.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at crates/codex-plus-core/src/dream_skin_library.rs:540

    }
    if !draft.config.style_preset.is_empty() && !valid_theme_id(&draft.config.style_preset) {
        bail!("invalid Dream Skin style preset");
    }
    if let Some(colors) = &draft.config.colors {
        for color in [
            &colors.background,
            &colors.panel,
            &colors.panel_alt,
            &colors.accent,
            &colors.accent_alt,
            &colors.secondary,
            &colors.highlight,
            &colors.text,
            &colors.muted,
            &colors.line,
        ] {
            if !valid_css_color(color) {
                bail!("invalid Dream Skin theme color: {color}");
            }
        }
    }
    Ok(())
}

fn valid_css_color(value: &str) -> bool {
    let value = value.trim();
    if let Some(hex) = value.strip_prefix('#') {
        return matches!(hex.len(), 3 | 4 | 6 | 8)
            && hex.bytes().all(|byte| byte.is_ascii_hexdigit());
    }
    let body = value
        .strip_prefix("rgb(")
        .or_else(|| value.strip_prefix("rgba("))
        .and_then(|value| value.strip_suffix(')'));
    body.is_some_and(|body| {
        !body.is_empty()

View on GitHub (pinned to b1ed92e5e4)