{"record":{"id":"2b15cfee1cea1042","repo":"BigPizzaV3/CodexPlusPlus","slug":"built-in-dream-skin-theme-cannot-be-deleted","errorCode":null,"errorMessage":"built-in Dream Skin theme cannot be deleted","messagePattern":"built-in Dream Skin theme cannot be deleted","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_library.rs","lineNumber":505,"sourceCode":"    state_dir: &Path,\n    id: &str,\n    active_id: Option<&str>,\n) -> anyhow::Result<()> {\n    if !valid_theme_id(id) {\n        bail!(\"invalid Dream Skin theme id\");\n    }\n    if active_id.is_some_and(|active| active == id) {\n        bail!(\"current Dream Skin theme cannot be deleted\");\n    }\n    let directory = state_dir.join(THEMES_DIR).join(id);\n    let metadata = std::fs::symlink_metadata(&directory)\n        .with_context(|| format!(\"Dream Skin theme not found: {id}\"))?;\n    if !metadata.file_type().is_dir() || metadata.file_type().is_symlink() {\n        bail!(\"Dream Skin theme path is not a safe directory\");\n    }\n    let stored = load_stored_dream_skin_theme(state_dir, id)?;\n    if stored.config.id == DreamSkinThemeConfig::default().id {\n        bail!(\"built-in Dream Skin theme cannot be deleted\");\n    }\n    remove_known_theme_directory(&directory)\n}\n\nfn validate_theme_draft(draft: &DreamSkinThemeDraft) -> anyhow::Result<()> {\n    if draft.builtin {\n        bail!(\"built-in Dream Skin theme is read-only\");\n    }\n    if !valid_theme_id(&draft.config.id) {\n        bail!(\"invalid Dream Skin theme id\");\n    }\n    if draft.config.schema_version != 1 {\n        bail!(\"unsupported Dream Skin theme schema\");\n    }\n    if draft.config.name.trim().is_empty() {\n        bail!(\"Dream Skin theme name is empty\");\n    }\n    if !draft.config.style_preset.is_empty() && !valid_theme_id(&draft.config.style_preset) {","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_library.rs#L487-L523","documentation":"Before removing the directory, delete_dream_skin_theme loads the stored theme and compares its config.id against DreamSkinThemeConfig::default().id (the built-in theme's id). Built-in themes ship with the app and cannot be deleted. The error is a deliberate protection of first-party/default themes.","triggerScenarios":"Calling delete_dream_skin_theme(state_dir, id, active_id) where id resolves to a stored theme whose config.json contains the default/built-in id (the id of a fresh DreamSkinThemeConfig::default()).","commonSituations":"Attempting to clean up the default theme created on first run; batch-delete of all themes in the library; a theme saved earlier with the default id because the draft's id was never set from the default config.","solutions":["Skip the built-in theme in your delete loop (compare id against the built-in/default id) rather than treating it as an error.","If you want a different look, create a new custom theme and switch to it instead of deleting the built-in one.","If a custom theme wrongly carries the default id (bug during creation), recreate it via save_dream_skin_theme with a proper unique id, then delete the original non-builtin copy or fix its theme.json id manually."],"exampleFix":"// before\nfor theme in themes {\n    delete_dream_skin_theme(&state_dir, &theme.config.id, Some(&active_id))?; // hits built-in\n}\n// after\nconst BUILTIN_ID: &str = DreamSkinThemeConfig::default().id.as_str();\nfor theme in themes.filter(|t| t.config.id != BUILTIN_ID) {\n    delete_dream_skin_theme(&state_dir, &theme.config.id, Some(&active_id))?;\n}","handlingStrategy":"validation","validationCode":"let builtin_id = DreamSkinThemeConfig::default().id;\nif id == builtin_id { return; } // skip built-in in delete flows","typeGuard":null,"tryCatchPattern":"match delete_dream_skin_theme(&state_dir, &id, active) {\n    Err(e) if e.to_string().contains(\"built-in\") => { /* skip, expected for default theme */ }\n    other => other?,\n}","preventionTips":["Filter out the built-in id in any 'delete all themes' loop.","Offer 'reset to default' instead of delete for the built-in theme.","Ensure custom themes get unique non-default ids at creation time."],"tags":["validation","protected-resource","theme","rust"],"backgroundTag":"unsupported-operation","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"}