{"record":{"id":"af7f6a81141434e9","repo":"BigPizzaV3/CodexPlusPlus","slug":"id","errorCode":null,"errorMessage":"同 ID 本地主题身份不一致，已拒绝覆盖","messagePattern":"同 ID 本地主题身份不一致，已拒绝覆盖","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_library.rs","lineNumber":321,"sourceCode":"    let config: DreamSkinThemeConfig = serde_json::from_value(package.theme.clone())\n        .context(\"主题包 theme.json 与 Codex++ 主题配置不兼容\")?;\n    let draft = DreamSkinThemeDraft {\n        config: config.clone(),\n        image_path: String::new(),\n        builtin: false,\n    };\n    validate_theme_draft(&draft)?;\n\n    let themes_dir = state_dir.join(THEMES_DIR);\n    std::fs::create_dir_all(&themes_dir)\n        .with_context(|| format!(\"failed to create {}\", themes_dir.display()))?;\n    reject_symlink(&themes_dir)?;\n    let target = themes_dir.join(&config.id);\n    if target.exists() {\n        let existing = load_stored_dream_skin_theme(state_dir, &config.id)\n            .context(\"同 ID 本地主题无法确认身份，已拒绝覆盖\")?;\n        if existing.config.id != config.id {\n            bail!(\"同 ID 本地主题身份不一致，已拒绝覆盖\");\n        }\n    }\n    let suffix = unique_suffix();\n    let staging = themes_dir.join(format!(\".stage-{}-{suffix}\", config.id));\n    std::fs::create_dir(&staging).with_context(|| {\n        format!(\n            \"failed to create Dream Skin package staging directory {}\",\n            staging.display()\n        )\n    })?;\n    let staged = (|| -> anyhow::Result<()> {\n        let image_extension = match package.image_name.as_str() {\n            \"background.webp\" => \"webp\",\n            \"background.jpg\" => \"jpg\",\n            \"background.png\" => \"png\",\n            other => bail!(\"unsupported Dream Skin package image: {other}\"),\n        };\n        crate::settings::atomic_write(","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_library.rs#L303-L339","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Inspect the existing directory's theme.json and fix its id to match the directory name, or remove the stale directory explicitly","Save under a different theme id if the new package is genuinely a different theme","Use the library's rename/delete APIs instead of touching the theme directories by hand","If a failed prior save left debris, delete only that specific theme directory and re-run the save"],"exampleFix":"// before (stale on-disk state)\n// themes/<id>/theme.json has \"id\": \"old-id\" but folder renamed to \"new-id\"\n// after: fix stored identity to match directory\n// themes/new-id/theme.json -> \"id\": \"new-id\"","handlingStrategy":"validation","validationCode":"if themes_dir.join(&config.id).exists() {\n    match load_stored_dream_skin_theme(state_dir, &config.id) {\n        Ok(existing) if existing.config.id == config.id => {}, // safe to overwrite\n        Ok(_) | Err(_) => return Err(anyhow::anyhow!(\"existing theme identity for '{}' cannot be confirmed; pick a new id or fix/remove the directory\", config.id)),\n    }\n}","typeGuard":null,"tryCatchPattern":"match save_validated_dream_skin_package(&state_dir, &package) {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"身份不一致\") => prompt_user(\"a different theme occupies this id; choose another id or delete the old theme\"),\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Never rename or hand-edit theme directories/configs on disk — use the library APIs","Before importing, check whether the target id already exists and surface a conflict dialog","After backups/restores, re-validate stored themes with load_stored_dream_skin_theme"],"tags":["identity-mismatch","file-conflict","validation"],"backgroundTag":"conflicting-config-options","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}