{"record":{"id":"ce153a4f9dc1ffba","repo":"BigPizzaV3/CodexPlusPlus","slug":"prepared-dream-skin-image-is-empty","errorCode":null,"errorMessage":"prepared Dream Skin image is empty","messagePattern":"prepared Dream Skin image is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin.rs","lineNumber":80,"sourceCode":"\n    let extension = supported_image_extension(source)?;\n    std::fs::create_dir_all(destination_dir).with_context(|| {\n        format!(\n            \"failed to create Dream Skin theme directory {}\",\n            destination_dir.display()\n        )\n    })?;\n\n    let (prepared_path, prepared_extension) = prepare_image(source, destination_dir, &extension)?;\n    let prepared_metadata = std::fs::metadata(&prepared_path).with_context(|| {\n        format!(\n            \"failed to read prepared image metadata {}\",\n            prepared_path.display()\n        )\n    })?;\n    if prepared_metadata.len() == 0 {\n        remove_prepared_copy(source, &prepared_path);\n        bail!(\"prepared Dream Skin image is empty\");\n    }\n    if prepared_metadata.len() > DREAM_SKIN_PREPARED_LIMIT {\n        remove_prepared_copy(source, &prepared_path);\n        bail!(\"prepared Dream Skin image exceeds 16 MiB\");\n    }\n\n    let destination = destination_dir.join(format!(\"{destination_stem}.{prepared_extension}\"));\n    let bytes = std::fs::read(&prepared_path)\n        .with_context(|| format!(\"failed to read prepared image {}\", prepared_path.display()))?;\n    crate::settings::atomic_write(&destination, &bytes)\n        .with_context(|| format!(\"failed to store Dream Skin image {}\", destination.display()))?;\n    remove_prepared_copy(source, &prepared_path);\n    Ok(destination)\n}\n\npub fn clear_managed_dream_skin_image(state_dir: &Path) -> anyhow::Result<()> {\n    let managed_dir = state_dir.join(MANAGED_THEME_DIR);\n    if !managed_dir.is_dir() {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin.rs#L62-L98","documentation":"After preparing (possibly transcoding) the image into a prepared copy, the function re-checks its size and bails if the prepared file is 0 bytes, cleaning up the prepared copy first. This catches transcoders/converters that silently produce empty output.","triggerScenarios":"prepare_image (platform-specific, e.g. macOS sips pipeline) writes a prepared file whose metadata.len() == 0; the function removes the prepared copy and bails.","commonSituations":"A platform image tool (sips on macOS) failing silently on an unusual format; disk-full conditions during conversion; a converter writing a placeholder file then crashing.","solutions":["Re-run the import; transient disk/converter failures may not recur after freeing space.","Verify the source image opens in a native viewer; re-export it in a standard format (PNG/JPEG).","Check available disk space in the destination directory and temp location.","If it persists, run the platform converter manually (e.g. 'sips -s format png in.webp --out out.png') to see its real error."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"let md = std::fs::metadata(&prepared_path)?;\nif md.len() == 0 {\n    // rerun the platform conversion once after freeing disk space / checking tools\n    std::fs::remove_file(&prepared_path).ok();\n    prepare_image(&source, &prepared_path)?;\n    anyhow::ensure!(std::fs::metadata(&prepared_path)?.len() > 0, \"conversion still empty\");\n}","typeGuard":null,"tryCatchPattern":"// Rust\nmatch import_dream_skin_image(&src, &dir, &stem) {\n    Err(e) if e.to_string().contains(\"prepared Dream Skin image is empty\") => {\n        // free disk space, verify image opens, then retry once\n        retry_import_with_clean_temp(&src, &dir, &stem)\n    }\n    other => other,\n}","preventionTips":["Monitor free disk space before running image conversions","Validate source images in a standard viewer before import","Test the platform converter (sips/ImageMagick) directly when imports fail repeatedly"],"tags":["filesystem","image-processing","empty-file"],"backgroundTag":"file-write-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"}