invoke-ai/InvokeAI · error

Neither old nor new image file exists for {item.image_name}

Error message

Neither old nor new image file exists for {item.image_name}

What it means

Raised by _complete_partial_filesystem_move when neither the old nor the new image file exists for an item being completed. The move record says there should be a file in one of the two locations, but the underlying image has vanished, so completion cannot proceed for non-intermediate images (intermediates are tolerated via _mark_missing_intermediate_moved).

Source

Thrown at invokeai/app/services/image_moves/image_moves_default.py:511

        new_thumbnail_path = self.image_files.get_path(
            item.image_name, thumbnail=True, image_subfolder=item.new_subfolder
        )
        old_exists = old_path.exists()
        new_exists = new_path.exists()
        if old_exists and new_exists:
            raise RuntimeError(f"Both old and new image files exist for {item.image_name}")
        if not old_exists and not new_exists:
            if item.is_intermediate:
                self._mark_missing_intermediate_moved(
                    job_id=job_id,
                    image_name=item.image_name,
                    old_path=old_path,
                    new_path=new_path,
                    old_thumbnail_path=old_thumbnail_path,
                    new_thumbnail_path=new_thumbnail_path,
                )
                return
            raise RuntimeError(f"Neither old nor new image file exists for {item.image_name}")

        old_thumbnail_exists = old_thumbnail_path.exists()
        new_thumbnail_exists = new_thumbnail_path.exists()
        if (
            old_exists
            and not new_exists
            and (
                (not old_thumbnail_exists and not new_thumbnail_exists)
                or (old_thumbnail_exists and new_thumbnail_exists)
            )
        ):
            # Generate the thumbnail while the source is still available. If this fails,
            # leave the source untouched so transient failures can be retried and corrupt
            # images can be repaired or removed by the operator.
            self._regenerate_thumbnail(old_path, new_thumbnail_path)

        if not old_exists and new_exists and not old_thumbnail_exists and not new_thumbnail_exists:
            self._regenerate_thumbnail(new_path, new_thumbnail_path)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Confirm the image is truly gone (search all subfolders for the image_name); if found, move it to the expected old or new path and re-run recovery.
  2. If the image is intentionally deleted, delete the corresponding image_subfolder_move_items row (and image DB record) so completion no longer expects the file.
  3. For intermediates, verify the is_intermediate flag is set correctly; missing intermediates are tolerated and marked moved automatically.
  4. Check for case-sensitivity or subfolder naming mismatches between DB old_subfolder/new_subfolder and the on-disk layout.

Example fix

// before: DB row expects file that was deleted
SELECT image_name FROM image_subfolder_move_items WHERE job_id = 7 AND state = 'planned';
// after: remove orphaned item for intentionally deleted image
DELETE FROM image_subfolder_move_items WHERE job_id = 7 AND image_name = 'missing.png';
DELETE FROM images WHERE image_name = 'missing.png';
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
def item_file_missing(item) -> bool:
    return not item.old_path.exists() and not item.new_path.exists()
# pre-check each planned item before completing

Type guard

def file_available(paths: list[Path]) -> bool:
    return any(p.exists() for p in paths)

Try / catch

try:
    service.complete_partial_filesystem_moves(job_id)
except RuntimeError as e:
    if "Neither old nor new image file exists" in str(e):
        # image gone: drop the item/record instead of retrying
        ...

Prevention

When it happens

Trigger: complete_partial_filesystem_moves processing an item whose image was deleted from disk (manually, by a cleanup job, or by a failed earlier move that removed the source before writing the destination), or an incorrect new_subfolder recorded in the DB pointing at the wrong folder.

Common situations: User deleted images directly on disk while a move job was pending; disk/restore lost files; intermediates cleanup raced with a move job; DB rows referencing images removed by 'Delete all images' during a pending move.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/cbf4a60ccf791670. Report an issue: GitHub.