BigPizzaV3/CodexPlusPlus · error
current Dream Skin theme cannot be deleted
Error message
current Dream Skin theme cannot be deleted
What it means
delete_dream_skin_theme refuses to delete the theme whose id equals the active_id parameter, since deleting the currently active Dream Skin theme would leave the UI referencing a missing theme. The check runs after id validation and before any filesystem access. Passing the active theme's id here is an API-contract violation, not a filesystem problem.
Solutions
- Switch the active theme to another valid theme (update stored active_id) before calling delete on the current one.
- Check active_id before calling and skip or surface a user-facing 'cannot delete active theme' message.
- If the caller doesn't know the active theme, load it from config/state first and pass it correctly — do NOT pass None as a workaround when the theme actually is active.
Example fix
// before
delete_dream_skin_theme(&state_dir, &theme_id, Some(&active_id))?; // panics when equal
// after
if theme_id == active_id {
let fallback = themes.iter().find(|t| t.config.id != active_id)
.ok_or_else(|| anyhow!("no other theme to activate"))?;
set_active_dream_skin_theme(&state_dir, &fallback.config.id)?;
}
delete_dream_skin_theme(&state_dir, &theme_id, Some(&active_id))?; Defensive patterns
Strategy: validation
Validate before calling
if let Some(active) = active_id {
if active == id { return Err(anyhow!("switch away from the active theme before deleting it")); }
} Try / catch
match delete_dream_skin_theme(&state_dir, &id, active_id) {
Err(e) if e.to_string().contains("cannot be deleted") => ui_show("Cannot delete the active theme; switch first"),
other => other?,
} Prevention
- Disable the delete action in the UI while a theme is active.
- In batch deletes, always skip or re-activate away from the current theme first.
- Keep active_id in sync — load it from state immediately before deleting.
When it happens
Trigger: Calling delete_dream_skin_theme(state_dir, id, Some(id)) — i.e. Some(&active_theme_id) where the id being deleted equals the currently active theme's id.
Common situations: UI delete button enabled while the theme is active; batch-delete loops that don't skip the active theme; stale active_id state in config so the caller believes another theme is active; calling with active_id that was updated after theme switch but before delete.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- built-in Dream Skin theme cannot be deleted
- built-in Dream Skin theme is read-only
- Dream Skin theme name is empty
- Dream Skin theme must contain exactly one image
- 无效的主题市场相对路径
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/56a41bd6dca031dd.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/dream_skin_library.rs:495
.with_context(|| format!("failed to remove old image {}", path.display()))?;
}
}
Ok(DreamSkinActivation {
config: draft.config.clone(),
active_image_path: active_image.to_string_lossy().into_owned(),
})
}
pub fn delete_dream_skin_theme(
state_dir: &Path,
id: &str,
active_id: Option<&str>,
) -> anyhow::Result<()> {
if !valid_theme_id(id) {
bail!("invalid Dream Skin theme id");
}
if active_id.is_some_and(|active| active == id) {
bail!("current Dream Skin theme cannot be deleted");
}
let directory = state_dir.join(THEMES_DIR).join(id);
let metadata = std::fs::symlink_metadata(&directory)
.with_context(|| format!("Dream Skin theme not found: {id}"))?;
if !metadata.file_type().is_dir() || metadata.file_type().is_symlink() {
bail!("Dream Skin theme path is not a safe directory");
}
let stored = load_stored_dream_skin_theme(state_dir, id)?;
if stored.config.id == DreamSkinThemeConfig::default().id {
bail!("built-in Dream Skin theme cannot be deleted");
}
remove_known_theme_directory(&directory)
}
fn validate_theme_draft(draft: &DreamSkinThemeDraft) -> anyhow::Result<()> {
if draft.builtin {
bail!("built-in Dream Skin theme is read-only");
}View on GitHub (pinned to b1ed92e5e4)