{"record":{"id":"1f683fd2698beeed","repo":"BigPizzaV3/CodexPlusPlus","slug":"invalid-dream-skin-theme-config","errorCode":null,"errorMessage":"invalid Dream Skin theme config","messagePattern":"invalid Dream Skin theme config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_library.rs","lineNumber":386,"sourceCode":"    id: &str,\n) -> anyhow::Result<DreamSkinThemeDraft> {\n    if !valid_theme_id(id) {\n        bail!(\"invalid Dream Skin theme id\");\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 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,","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_library.rs#L368-L404","documentation":"load_stored_dream_skin_theme validates the theme's config file (theme.json): it must be a regular file, not a symlink, and its size must not exceed THEME_CONFIG_LIMIT (256 KiB). Any violation bails with \"invalid Dream Skin theme config\", keeping stored themes within safe, parseable bounds.","triggerScenarios":"The stored theme's config file is a symlink, is a directory or other non-file, or exceeds 256 KiB on disk when loading a theme via any of the public entry points (load, save with existing id, rename, delete, create-from-image).","commonSituations":"An oversized config was written by an older/broken version or hand-edited; a dotfile manager replaced the config with a symlink; restore tooling left a corrupted entry where theme.json should be.","solutions":["Shrink theme.json below 256 KiB (remove embedded blobs, minify) or regenerate the theme via the library API","Replace any symlinked config with a real file at themes/<id>/theme.json","Delete the broken theme and re-create it with create_dream_skin_theme_from_image","Check disk/file for corruption (`wc -c` the file) to confirm which invariant failed"],"exampleFix":"// before\n// themes/my-theme/theme.json is a symlink or 300 KiB\n// after\nrm themes/my-theme/theme.json   # drop symlink/oversized file\n# recreate the theme through the library so a valid config is written","handlingStrategy":"validation","validationCode":"let path = state_dir.join(\"themes\").join(id).join(\"theme.json\");\nlet md = std::fs::symlink_metadata(&path)?;\nif !md.file_type().is_file() || md.file_type().is_symlink() || md.len() > THEME_CONFIG_LIMIT {\n    return Err(anyhow::anyhow!(\"theme.json for '{id}' is not a plain file under 256 KiB\"));\n}","typeGuard":"fn is_safe_theme_config(path: &std::path::Path) -> bool {\n    match std::fs::symlink_metadata(path) {\n        Ok(md) => md.file_type().is_file() && !md.file_type().is_symlink() && md.len() <= THEME_CONFIG_LIMIT,\n        Err(_) => false,\n    }\n}","tryCatchPattern":"match load_stored_dream_skin_theme(&state_dir, &id) {\n    Ok(draft) => use(draft),\n    Err(e) if e.to_string().contains(\"invalid Dream Skin theme config\") => eprintln!(\"theme.json for {id} is oversized or not a regular file; recreate the theme\"),\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Keep theme configs small; store images separately from theme.json","Don't symlink config files via dotfile managers","Recreate themes through the library after restores or version upgrades"],"tags":["file-size-limit","symlink","config-validation"],"backgroundTag":"file-size-limit-exceeded","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"}