{"record":{"id":"b782325724f3d102","repo":"BigPizzaV3/CodexPlusPlus","slug":"dream-skin-image-is-not-a-file","errorCode":null,"errorMessage":"Dream Skin image is not a file","messagePattern":"Dream Skin image is not a file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin.rs","lineNumber":54,"sourceCode":"    Ok(destination)\n}\n\npub(crate) fn prepare_dream_skin_image_for_directory(\n    source: &Path,\n    destination_dir: &Path,\n    destination_stem: &str,\n) -> anyhow::Result<PathBuf> {\n    if destination_stem.is_empty()\n        || !destination_stem\n            .bytes()\n            .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'-' | b'_'))\n    {\n        bail!(\"invalid Dream Skin destination name\");\n    }\n    let metadata = std::fs::symlink_metadata(source)\n        .with_context(|| format!(\"failed to read image metadata {}\", source.display()))?;\n    if !metadata.file_type().is_file() || metadata.file_type().is_symlink() {\n        bail!(\"Dream Skin image is not a file\");\n    }\n    if metadata.len() == 0 {\n        bail!(\"Dream Skin image is empty\");\n    }\n    if metadata.len() > DREAM_SKIN_SOURCE_LIMIT {\n        bail!(\"Dream Skin source image exceeds 50 MiB\");\n    }\n\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(|| {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin.rs#L36-L72","documentation":"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.","triggerScenarios":"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).","commonSituations":"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).","solutions":["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.","Check the selection is an image file (not a directory) before importing.","On macOS, resolve /tmp -> /private/tmp style aliases before passing the path."],"exampleFix":"// before\nimport_dream_skin_image(&symlinked_path, &dir, &stem)?;\n// after\nlet real = std::fs::canonicalize(&symlinked_path)?;\nif real.is_file() {\n    import_dream_skin_image(&real, &dir, &stem)?;\n}","handlingStrategy":"validation","validationCode":"let md = std::fs::symlink_metadata(&source)?;\nanyhow::ensure!(md.is_file(), \"source must be a regular file, not a symlink/dir\");","typeGuard":"fn is_regular_file_no_symlink(p: &std::path::Path) -> bool {\n    std::fs::symlink_metadata(p).map_or(false, |md| md.is_file() && !md.file_type().is_symlink())\n}","tryCatchPattern":null,"preventionTips":["Resolve symlinks with canonicalize before importing images from sync/temp folders","Restrict file pickers to image file types, not directories","On macOS, expand /tmp-style aliases before passing paths"],"tags":["filesystem","validation","symlink"],"backgroundTag":"incompatible-source-type","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"}