BigPizzaV3/CodexPlusPlus · error

同 ID 本地主题身份不一致,已拒绝覆盖

Error message

同 ID 本地主题身份不一致,已拒绝覆盖

What it means

save_validated_dream_skin_package refuses to overwrite an existing theme directory whose stored identity cannot be confirmed to match. When the target directory exists, it loads the stored theme; if loading succeeded but the stored config's id differs from the requested config.id, it bails — a safety check against clobbering a different theme under the same directory path.

Solutions

  1. Inspect the existing directory's theme.json and fix its id to match the directory name, or remove the stale directory explicitly
  2. Save under a different theme id if the new package is genuinely a different theme
  3. Use the library's rename/delete APIs instead of touching the theme directories by hand
  4. If a failed prior save left debris, delete only that specific theme directory and re-run the save

Example fix

// before (stale on-disk state)
// themes/<id>/theme.json has "id": "old-id" but folder renamed to "new-id"
// after: fix stored identity to match directory
// themes/new-id/theme.json -> "id": "new-id"
Defensive patterns

Strategy: validation

Validate before calling

if themes_dir.join(&config.id).exists() {
    match load_stored_dream_skin_theme(state_dir, &config.id) {
        Ok(existing) if existing.config.id == config.id => {}, // safe to overwrite
        Ok(_) | Err(_) => return Err(anyhow::anyhow!("existing theme identity for '{}' cannot be confirmed; pick a new id or fix/remove the directory", config.id)),
    }
}

Try / catch

match save_validated_dream_skin_package(&state_dir, &package) {
    Ok(()) => {},
    Err(e) if e.to_string().contains("身份不一致") => prompt_user("a different theme occupies this id; choose another id or delete the old theme"),
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling save_validated_dream_skin_package with an id whose directory already exists under themes_dir, and the stored theme's config.id differs from the incoming config.id (e.g. directory was renamed on disk or hand-edited config.id no longer matches the folder name).

Common situations: A theme directory was manually renamed or its config.json id field edited externally; a partially failed previous save left an inconsistent directory; state_dir contents moved between machines or restored from a partial backup.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

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

    let config: DreamSkinThemeConfig = serde_json::from_value(package.theme.clone())
        .context("主题包 theme.json 与 Codex++ 主题配置不兼容")?;
    let draft = DreamSkinThemeDraft {
        config: config.clone(),
        image_path: String::new(),
        builtin: false,
    };
    validate_theme_draft(&draft)?;

    let themes_dir = state_dir.join(THEMES_DIR);
    std::fs::create_dir_all(&themes_dir)
        .with_context(|| format!("failed to create {}", themes_dir.display()))?;
    reject_symlink(&themes_dir)?;
    let target = themes_dir.join(&config.id);
    if target.exists() {
        let existing = load_stored_dream_skin_theme(state_dir, &config.id)
            .context("同 ID 本地主题无法确认身份,已拒绝覆盖")?;
        if existing.config.id != config.id {
            bail!("同 ID 本地主题身份不一致,已拒绝覆盖");
        }
    }
    let suffix = unique_suffix();
    let staging = themes_dir.join(format!(".stage-{}-{suffix}", config.id));
    std::fs::create_dir(&staging).with_context(|| {
        format!(
            "failed to create Dream Skin package staging directory {}",
            staging.display()
        )
    })?;
    let staged = (|| -> anyhow::Result<()> {
        let image_extension = match package.image_name.as_str() {
            "background.webp" => "webp",
            "background.jpg" => "jpg",
            "background.png" => "png",
            other => bail!("unsupported Dream Skin package image: {other}"),
        };
        crate::settings::atomic_write(

View on GitHub (pinned to b1ed92e5e4)