{"record":{"id":"66c84b2cc2b32be7","repo":"BigPizzaV3/CodexPlusPlus","slug":"dream-skin-theme-id-does-not-match-directory","errorCode":null,"errorMessage":"Dream Skin theme id does not match directory","messagePattern":"Dream Skin theme id does not match directory","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_library.rs","lineNumber":390,"sourceCode":"    }\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 config_path = directory.join(THEME_CONFIG_FILE);\n    let metadata = std::fs::symlink_metadata(&config_path)\n        .with_context(|| format!(\"Dream Skin theme config not found: {id}\"))?;\n    if !metadata.file_type().is_file()\n        || metadata.file_type().is_symlink()\n        || metadata.len() > THEME_CONFIG_LIMIT\n    {\n        bail!(\"invalid Dream Skin theme config\");\n    }\n    let config: DreamSkinThemeConfig = serde_json::from_slice(&std::fs::read(&config_path)?)?;\n    if config.id != id {\n        bail!(\"Dream Skin theme id does not match directory\");\n    }\n    let image = find_theme_image(&directory)\n        .ok_or_else(|| anyhow::anyhow!(\"Dream Skin theme must contain exactly one image\"))?;\n    let draft = DreamSkinThemeDraft {\n        config,\n        image_path: image.to_string_lossy().into_owned(),\n        builtin: false,\n    };\n    validate_theme_draft(&draft)?;\n    Ok(draft)\n}\n\npub fn rename_dream_skin_theme(\n    state_dir: &Path,\n    id: &str,\n    name: &str,\n) -> anyhow::Result<DreamSkinThemeSummary> {\n    let mut draft = load_stored_dream_skin_theme(state_dir, id)?;","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_library.rs#L372-L408","documentation":"After successfully parsing the stored config JSON, load_stored_dream_skin_theme requires that config.id equals the directory-name id argument. A mismatch bails with \"Dream Skin theme id does not match directory\" — the on-disk identity must be self-consistent before the theme is used, renamed, or deleted.","triggerScenarios":"theme.json inside themes/<id>/ contains an id field different from <id> — typically after the directory was renamed manually, the id was hand-edited, or a theme was copied to a new folder name without updating its config.","commonSituations":"Duplicating a theme folder to \"fork\" it but forgetting to change the inner id; renaming via the file manager instead of rename_dream_skin_theme; merging theme directories from backups where names collide.","solutions":["Edit themes/<id>/theme.json so its \"id\" equals the directory name <id>","Use the library's rename_dream_skin_theme API instead of renaming directories on disk","Delete the inconsistent directory and recreate the theme through the public API","When forking a theme manually, update both the folder name and the config id together"],"exampleFix":"// before\n// themes/ocean/theme.json -> { \"id\": \"sunset\", ... }\n// after\n// themes/ocean/theme.json -> { \"id\": \"ocean\", ... }","handlingStrategy":"validation","validationCode":"let cfg: DreamSkinThemeConfig = serde_json::from_slice(&std::fs::read(themes_dir.join(id).join(\"theme.json\"))?)?;\nif cfg.id != id {\n    return Err(anyhow::anyhow!(\"config id '{}' does not match directory '{id}'\", cfg.id));\n}","typeGuard":"fn ids_are_consistent(dir_name: &str, cfg: &DreamSkinThemeConfig) -> bool {\n    cfg.id == dir_name\n}","tryCatchPattern":"match load_stored_dream_skin_theme(&state_dir, &id) {\n    Ok(draft) => use(draft),\n    Err(e) if e.to_string().contains(\"does not match directory\") => eprintln!(\"fix the 'id' in themes/{id}/theme.json to equal '{id}', or recreate the theme\"),\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Always rename themes via rename_dream_skin_theme, never by renaming folders","When duplicating a theme to fork it, update the inner config id to the new name","Run a consistency pass over the themes directory after backups or manual edits"],"tags":["identity-mismatch","consistency","validation"],"backgroundTag":"schema-validation-failed","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"}