{"record":{"id":"c0defb3f96de1057","repo":"BigPizzaV3/CodexPlusPlus","slug":"dream-skin-theme-config-exceeds-256-kib","errorCode":null,"errorMessage":"Dream Skin theme config exceeds 256 KiB","messagePattern":"Dream Skin theme config exceeds 256 KiB","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_library.rs","lineNumber":283,"sourceCode":"            \"failed to create theme staging directory {}\",\n            staging.display()\n        )\n    })?;\n\n    let staged = (|| -> anyhow::Result<()> {\n        if draft.image_path.trim().is_empty() {\n            let (_, bytes) = crate::assets::dream_skin_default_image();\n            crate::settings::atomic_write(&staging.join(\"image.png\"), bytes)?;\n        } else {\n            crate::dream_skin::prepare_dream_skin_image_for_directory(\n                Path::new(draft.image_path.trim()),\n                &staging,\n                \"image\",\n            )?;\n        }\n        let config = serde_json::to_vec_pretty(&draft.config)?;\n        if config.len() as u64 > THEME_CONFIG_LIMIT {\n            bail!(\"Dream Skin theme config exceeds 256 KiB\");\n        }\n        crate::settings::atomic_write(&staging.join(THEME_CONFIG_FILE), &config)?;\n        Ok(())\n    })();\n    if let Err(error) = staged {\n        let _ = remove_known_theme_directory(&staging);\n        return Err(error);\n    }\n\n    let target = themes_dir.join(&draft.config.id);\n    replace_theme_directory(&staging, &target, &suffix)?;\n    let stored = load_stored_dream_skin_theme(state_dir, &draft.config.id)?;\n    Ok(summary_from_draft(&stored, false, false))\n}\n\npub fn save_validated_dream_skin_package(\n    state_dir: &Path,\n    package: &crate::dream_skin_package::ValidatedDreamSkinPackage,","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_library.rs#L265-L301","documentation":"save_dream_skin_theme serializes the theme's config to pretty JSON and refuses to write it if it exceeds THEME_CONFIG_LIMIT (256 KiB), staging first and aborting the whole save on failure. This keeps on-disk theme configs bounded and prevents bloated or hostile configs from being persisted.","triggerScenarios":"Calling save_dream_skin_theme (directly or via create_dream_skin_theme_from_image / rename_dream_skin_theme) where serde_json::to_vec_pretty(&draft.config) yields more than 256 KiB — i.e. a config carrying huge embedded data (e.g. base64 blobs, massive CSS or metadata fields).","commonSituations":"A user pastes a giant custom CSS block into the theme config; tooling embeds an image as base64 in config instead of the image file; an imported theme JSON from elsewhere contains oversized fields.","solutions":["Trim the config: move large payloads (images, big CSS/data blobs) out of config into separate files (the image already is one)","Minify CSS and remove redundant fields from DreamSkinThemeConfig to shrink the serialized JSON","If a legitimate theme truly needs more space, raise THEME_CONFIG_LIMIT consciously (keeping load-side validation in sync)","Compress or strip whitespace — note pretty-printing adds bytes; storage uses to_vec_pretty so size gains must come from content, not formatting"],"exampleFix":"// before\nconfig.custom_css = std::fs::read_to_string(\"huge_theme.css\").unwrap(); // 300 KiB\n// after\nlet css = std::fs::read_to_string(\"theme.css\").unwrap();\nconfig.custom_css = minify_css(&css); // ensure serialized config stays < 256 KiB","handlingStrategy":"validation","validationCode":"let config_bytes = serde_json::to_vec_pretty(&draft.config)?;\nif config_bytes.len() as u64 > THEME_CONFIG_LIMIT {\n    return Err(anyhow::anyhow!(\n        \"theme config is {} bytes; max is {} — move large data out of config\",\n        config_bytes.len(), THEME_CONFIG_LIMIT\n    ));\n}","typeGuard":null,"tryCatchPattern":"match save_dream_skin_theme(&state_dir, draft) {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"256 KiB\") => warn_user(\"config too large: shrink CSS / remove embedded blobs\"),\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Keep images out of the config (they belong in image.<ext> files)","Minify CSS and drop default/empty fields from serialized configs","Enforce a soft client-side size warning well below 256 KiB"],"tags":["file-size-limit","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"}