BigPizzaV3/CodexPlusPlus · error

manifest.capabilities 无效或缺少 safe-css 能力

Error message

manifest.capabilities 无效或缺少 safe-css 能力

What it means

validate_manifest rejects the package when manifest.capabilities is empty, exceeds 3 entries, contains duplicates, lists any capability other than "background" | "tokens" | "safe-css", or omits the mandatory "safe-css" capability. The library requires every theme to declare it only injects safe CSS, plus optional background/tokens features. Thrown during validate_and_read_package.

Solutions

  1. Add "safe-css" to manifest.capabilities (it is mandatory)
  2. Limit capabilities to the allowed values: "background", "tokens", "safe-css"
  3. Remove duplicates and keep the list at 3 entries or fewer
  4. Remove unknown capability names or map them to supported ones
  5. Re-validate the package

Example fix

// before (manifest.json)
"capabilities": ["background"]
// after
"capabilities": ["background", "safe-css"]
Defensive patterns

Strategy: validation

Validate before calling

fn caps_ok(caps: &[String]) -> bool {
    !caps.is_empty() && caps.len() <= 3
        && caps.iter().all(|c| matches!(c.as_str(), "background" | "tokens" | "safe-css"))
        && caps.iter().any(|c| c == "safe-css")
}
if !caps_ok(&manifest.capabilities) { /* fix before calling */ }

Type guard

fn has_safe_css(caps: &[String]) -> bool {
    caps.iter().any(|c| c == "safe-css")
        && caps.iter().all(|c| matches!(c.as_str(), "background" | "tokens" | "safe-css"))
}

Try / catch

match validate_and_read_package(&path, platform) {
    Err(e) if e.to_string().contains("safe-css") => {
        eprintln!("package rejected: capabilities invalid or missing safe-css");
    }
    other => other?,
}

Prevention

When it happens

Trigger: validate_and_read_package reads a manifest whose capabilities array is [], has more than 3 entries, duplicates an entry, contains unknown values (e.g. "fonts", "js"), or lacks "safe-css" even when other valid capabilities are present.

Common situations: Old templates that predate the mandatory safe-css requirement; authors adding invented capability names; copying capability lists between packages incorrectly.

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

Appendix: source

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

            .platforms
            .iter()
            .any(|item| !matches!(item.as_str(), "macos" | "windows"))
    {
        bail!("manifest.platforms 无效");
    }
    if !manifest.platforms.iter().any(|item| item == platform) {
        bail!("主题包不支持当前平台:{platform}");
    }
    if manifest.capabilities.is_empty()
        || manifest.capabilities.len() > 3
        || has_duplicates(&manifest.capabilities)
        || manifest
            .capabilities
            .iter()
            .any(|item| !matches!(item.as_str(), "background" | "tokens" | "safe-css"))
        || !manifest.capabilities.iter().any(|item| item == "safe-css")
    {
        bail!("manifest.capabilities 无效或缺少 safe-css 能力");
    }
    if !safe_manifest_text(&manifest.publisher.display_name, 1, 80, false)
        || manifest.publisher.id.is_empty()
        || manifest.publisher.id.len() > 64
        || !manifest
            .publisher
            .id
            .bytes()
            .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b'-'))
        || manifest.license.is_empty()
        || manifest.license.len() > 64
        || !manifest.license.bytes().enumerate().all(|(index, byte)| {
            byte.is_ascii_alphanumeric()
                || (index > 0 && matches!(byte, b' ' | b'.' | b'+' | b'(' | b')' | b'-'))
        })
        || !safe_manifest_text(&manifest.provenance.summary, 1, 500, true)
    {
        bail!("manifest 发布者、许可证或来源说明为空");

View on GitHub (pinned to b1ed92e5e4)