{"record":{"id":"4df885d17340e8b3","repo":"BigPizzaV3/CodexPlusPlus","slug":"built-in-dream-skin-theme-is-read-only","errorCode":null,"errorMessage":"built-in Dream Skin theme is read-only","messagePattern":"built-in Dream Skin theme is read-only","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_library.rs","lineNumber":512,"sourceCode":"    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) {\n        bail!(\"invalid Dream Skin style preset\");\n    }\n    if let Some(colors) = &draft.config.colors {\n        for color in [\n            &colors.background,\n            &colors.panel,\n            &colors.panel_alt,","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_library.rs#L494-L530","documentation":"validate_theme_draft rejects any draft whose `builtin` flag is true: built-in themes are shipped/read-only and may never be re-saved or modified through the write path. The flag travels with the draft, so this fires for any mutating entry point (save, package import, activation prep) that received a builtin draft.","triggerScenarios":"Calling save_dream_skin_theme with a draft loaded from a built-in theme (builtin=true); importing a package containing a theme marked builtin; calling prepare_dream_skin_activation or load_stored_dream_skin_theme with a builtin-flagged draft that then goes through validation.","commonSituations":"Loading a built-in theme, tweaking colors, and re-saving it; copy-pasting a builtin draft and forgetting to set builtin=false; import tooling that preserves the builtin flag from a package manifest.","solutions":["Clone the built-in theme into a new draft with builtin=false and a fresh unique id, edit that, and save the copy.","When deriving from an existing draft, explicitly set draft.builtin = false after copying.","If editing built-ins is genuinely needed, modify the theme's theme.json on disk outside this API or ship a new built-in in the app's default list."],"exampleFix":"// before\nlet mut draft = load_stored_dream_skin_theme(&state_dir, \"midnight\")?.draft;\ndraft.config.colors = Some(new_colors);\nsave_dream_skin_theme(&state_dir, &draft)?; // builtin=true -> error\n// after\nlet mut draft = load_stored_dream_skin_theme(&state_dir, \"midnight\")?.draft;\ndraft.config.id = \"midnight-custom\".into();\ndraft.config.name = \"Midnight Custom\".into();\ndraft.builtin = false;\ndraft.config.colors = Some(new_colors);\nsave_dream_skin_theme(&state_dir, &draft)?;","handlingStrategy":"validation","validationCode":"if draft.builtin {\n    // clone instead of save\n    let mut copy = draft.clone();\n    copy.builtin = false;\n    copy.config.id = format!(\"{}-copy\", draft.config.id);\n}","typeGuard":"fn is_editable(draft: &DreamSkinThemeDraft) -> bool { !draft.builtin }","tryCatchPattern":"if let Err(e) = save_dream_skin_theme(&state_dir, &draft) {\n    if e.to_string().contains(\"read-only\") {\n        // fall back to save-as-copy flow\n    } else { return Err(e); }\n}","preventionTips":["Treat builtin=true drafts as immutable; always duplicate before editing.","In UI, show 'duplicate' not 'save' for built-in themes.","Reset builtin=false and assign a new id when importing packages derived from built-ins."],"tags":["validation","read-only","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"}