BigPizzaV3/CodexPlusPlus · error

Dream Skin image is not a file

Error message

Dream Skin image is not a file

What it means

After validating the name, the function reads the source image's symlink metadata and rejects anything that is not a regular file — directories and symbolic links both bail with 'Dream Skin image is not a file'. Symlinks are deliberately rejected to avoid copying files outside the intended location.

Solutions

  1. Pass a real regular-file path; resolve symlinks first with std::fs::canonicalize on the parent, or copy the target to a temp regular file.
  2. Check the selection is an image file (not a directory) before importing.
  3. On macOS, resolve /tmp -> /private/tmp style aliases before passing the path.

Example fix

// before
import_dream_skin_image(&symlinked_path, &dir, &stem)?;
// after
let real = std::fs::canonicalize(&symlinked_path)?;
if real.is_file() {
    import_dream_skin_image(&real, &dir, &stem)?;
}
Defensive patterns

Strategy: validation

Validate before calling

let md = std::fs::symlink_metadata(&source)?;
anyhow::ensure!(md.is_file(), "source must be a regular file, not a symlink/dir");

Type guard

fn is_regular_file_no_symlink(p: &std::path::Path) -> bool {
    std::fs::symlink_metadata(p).map_or(false, |md| md.is_file() && !md.file_type().is_symlink())
}

Prevention

When it happens

Trigger: import_dream_skin_image is called with a source path that is a directory, a symlink (even to a valid image), or a special file (fifo/device).

Common situations: User selects a folder instead of an image in the picker; the image lives behind a symlink (common with cloud-sync dirs like iCloud/Dropbox placeholders); OS temp paths that are symlinks (e.g. /tmp on macOS is /private/tmp).

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


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

Appendix: source

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

    Ok(destination)
}

pub(crate) fn prepare_dream_skin_image_for_directory(
    source: &Path,
    destination_dir: &Path,
    destination_stem: &str,
) -> anyhow::Result<PathBuf> {
    if destination_stem.is_empty()
        || !destination_stem
            .bytes()
            .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'-' | b'_'))
    {
        bail!("invalid Dream Skin destination name");
    }
    let metadata = std::fs::symlink_metadata(source)
        .with_context(|| format!("failed to read image metadata {}", source.display()))?;
    if !metadata.file_type().is_file() || metadata.file_type().is_symlink() {
        bail!("Dream Skin image is not a file");
    }
    if metadata.len() == 0 {
        bail!("Dream Skin image is empty");
    }
    if metadata.len() > DREAM_SKIN_SOURCE_LIMIT {
        bail!("Dream Skin source image exceeds 50 MiB");
    }

    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(|| {

View on GitHub (pinned to b1ed92e5e4)