BigPizzaV3/CodexPlusPlus · error

主题市场包含无效 ID:

Error message

主题市场包含无效 ID:{}

What it means

validate_market_theme requires every manifest theme's id to pass valid_theme_id (a restricted identifier format, e.g. safe path/filename characters only). Invalid IDs are rejected because the id is used to build filesystem paths and asset URLs, so malformed values could break installs or enable path tricks.

Solutions

  1. Change the theme id in the manifest to a simple identifier (ASCII letters, digits, hyphens/underscores per valid_theme_id) and keep it stable as the directory name
  2. Regenerate the manifest programmatically so ids are slugified rather than taken from display names
  3. If the theme is otherwise fine, republish it under a new valid id

Example fix

// before
{ "id": "Cool Theme/v2", ... }
// after
{ "id": "cool-theme-v2", "name": "Cool Theme v2", ... }
Defensive patterns

Strategy: validation

Validate before calling

fn id_is_valid(id: &str) -> bool {
    !id.is_empty()
        && id.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')
}
// reject manifest entries whose id fails id_is_valid before calling install

Try / catch

match install_market_theme(state_dir, &theme).await {
    Ok(s) => println!("installed {}", s.id),
    Err(e) if e.to_string().contains("无效 ID") => {
        eprintln!("theme id {:?} is not a valid identifier — use ASCII letters/digits/hyphens", theme.id);
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: install_market_theme_from_base or validate_manifest encounters a theme whose id contains characters outside the allowed set (spaces, slashes, unicode, path separators, empty string) — typically from a hand-written or malicious manifest entry.

Common situations: Theme authors naming entries with spaces or Chinese/emoji characters in the id; a manifest generated from directory names containing slashes; a hostile market testing path traversal via crafted ids.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at crates/codex-plus-core/src/dream_skin_market.rs:205

        bail!("不支持的主题市场清单版本");
    }
    if manifest.themes.len() > MARKET_THEME_COUNT_LIMIT {
        bail!("主题市场清单超过 {} 项限制", MARKET_THEME_COUNT_LIMIT);
    }
    let mut ids = HashSet::new();
    for theme in &mut manifest.themes {
        validate_market_theme(theme)?;
        if !ids.insert(theme.id.clone()) {
            bail!("主题市场清单包含重复 ID:{}", theme.id);
        }
        theme.preview_url = market_asset_url(DEFAULT_MARKET_RAW_BASE_URL, &theme.preview)?;
    }
    Ok(())
}

fn validate_market_theme(theme: &DreamSkinMarketTheme) -> anyhow::Result<()> {
    if !valid_theme_id(&theme.id) {
        bail!("主题市场包含无效 ID:{}", theme.id);
    }
    for (label, value, limit) in [
        ("名称", theme.name.as_str(), 100usize),
        ("版本", theme.version.as_str(), 40usize),
        ("作者", theme.author.as_str(), 100usize),
        ("许可证", theme.license.as_str(), 100usize),
    ] {
        if value.trim().is_empty() || value.len() > limit {
            bail!("市场主题 {} 的{}无效", theme.id, label);
        }
    }
    if theme.description.len() > 500 || theme.tags.len() > 12 {
        bail!("市场主题 {} 的描述或标签数量超过限制", theme.id);
    }
    if theme
        .tags
        .iter()
        .any(|tag| tag.trim().is_empty() || tag.len() > 32)

View on GitHub (pinned to b1ed92e5e4)