BigPizzaV3/CodexPlusPlus · error

theme.json.colors 缺少

Error message

theme.json.colors 缺少 {key}

What it means

After confirming the colors object has exactly 10 keys, validate_theme checks each required color key individually: its value must be a string passing valid_theme_color. If a key is missing, is not a string, or is not a valid theme color value, this error names the offending key. The message says "缺少" (missing) but also covers invalid/non-string values.

Solutions

  1. Add or fix the key named in the error message (e.g. "theme.json.colors 缺少 accent")
  2. Use valid hex color strings for every color value
  3. Ensure every value is a JSON string, not a number or null
  4. Fix key-name typos so all 10 required keys exist

Example fix

// before
"colors": { "accent": 5895055, "muted": null, ... }
// after
"colors": { "accent": "#58a6ff", "muted": "#7d8590", ... }
Defensive patterns

Strategy: validation

Validate before calling

const HEX = /^#[0-9a-fA-F]{3,8}$/;
for (const [k, v] of Object.entries(theme.colors ?? {})) {
  if (typeof v !== "string" || !HEX.test(v)) {
    throw new Error(`colors.${k} must be a valid hex color string`);
  }
}

Type guard

function isValidThemeColor(v) {
  return typeof v === "string" && /^#[0-9a-fA-F]{3,8}$/.test(v);
}

Prevention

When it happens

Trigger: Calling validate_and_read_package with a theme.json colors object where one of the 10 keys is absent, maps to a non-string (number/object/null), or its string fails valid_theme_color (e.g. not a proper hex color).

Common situations: Writing colors as numbers (16777215) instead of "#ffffff" hex strings; using rgb() or named colors where hex is required; a typo like "acccent" leaving "accent" missing; setting a value to null.

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/10e4697850f86d1d. Report an issue: GitHub.

Appendix: source

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

            "panelAlt",
            "accent",
            "accentAlt",
            "secondary",
            "highlight",
            "text",
            "muted",
            "line",
        ];
        if colors.len() != keys.len() {
            bail!("theme.json.colors 字段无效");
        }
        for key in keys {
            if colors
                .get(key)
                .and_then(Value::as_str)
                .is_none_or(|value| !valid_theme_color(value))
            {
                bail!("theme.json.colors 缺少 {key}");
            }
        }
    }
    Ok(())
}

fn validate_manifest_files(
    manifest: &DreamSkinPackageManifest,
    manifest_bytes: &[u8],
    theme_bytes: &[u8],
    css_bytes: &[u8],
    image_name: &str,
    image_bytes: &[u8],
    license_bytes: Option<&[u8]>,
) -> anyhow::Result<()> {
    let mut seen = HashSet::new();
    for file in &manifest.files {
        if !seen.insert(file.path.as_str())

View on GitHub (pinned to b1ed92e5e4)