BigPizzaV3/CodexPlusPlus · error

prepared Dream Skin image is empty

Error message

prepared Dream Skin image is empty

What it means

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.

Solutions

  1. Re-run the import; transient disk/converter failures may not recur after freeing space.
  2. Verify the source image opens in a native viewer; re-export it in a standard format (PNG/JPEG).
  3. Check available disk space in the destination directory and temp location.
  4. If it persists, run the platform converter manually (e.g. 'sips -s format png in.webp --out out.png') to see its real error.
Defensive patterns

Strategy: retry

Validate before calling

let md = std::fs::metadata(&prepared_path)?;
if md.len() == 0 {
    // rerun the platform conversion once after freeing disk space / checking tools
    std::fs::remove_file(&prepared_path).ok();
    prepare_image(&source, &prepared_path)?;
    anyhow::ensure!(std::fs::metadata(&prepared_path)?.len() > 0, "conversion still empty");
}

Try / catch

// Rust
match import_dream_skin_image(&src, &dir, &stem) {
    Err(e) if e.to_string().contains("prepared Dream Skin image is empty") => {
        // free disk space, verify image opens, then retry once
        retry_import_with_clean_temp(&src, &dir, &stem)
    }
    other => other,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/ce153a4f9dc1ffba. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/dream_skin.rs:80

    let extension = supported_image_extension(source)?;
    std::fs::create_dir_all(destination_dir).with_context(|| {
        format!(
            "failed to create Dream Skin theme directory {}",
            destination_dir.display()
        )
    })?;

    let (prepared_path, prepared_extension) = prepare_image(source, destination_dir, &extension)?;
    let prepared_metadata = std::fs::metadata(&prepared_path).with_context(|| {
        format!(
            "failed to read prepared image metadata {}",
            prepared_path.display()
        )
    })?;
    if prepared_metadata.len() == 0 {
        remove_prepared_copy(source, &prepared_path);
        bail!("prepared Dream Skin image is empty");
    }
    if prepared_metadata.len() > DREAM_SKIN_PREPARED_LIMIT {
        remove_prepared_copy(source, &prepared_path);
        bail!("prepared Dream Skin image exceeds 16 MiB");
    }

    let destination = destination_dir.join(format!("{destination_stem}.{prepared_extension}"));
    let bytes = std::fs::read(&prepared_path)
        .with_context(|| format!("failed to read prepared image {}", prepared_path.display()))?;
    crate::settings::atomic_write(&destination, &bytes)
        .with_context(|| format!("failed to store Dream Skin image {}", destination.display()))?;
    remove_prepared_copy(source, &prepared_path);
    Ok(destination)
}

pub fn clear_managed_dream_skin_image(state_dir: &Path) -> anyhow::Result<()> {
    let managed_dir = state_dir.join(MANAGED_THEME_DIR);
    if !managed_dir.is_dir() {

View on GitHub (pinned to b1ed92e5e4)