invoke-ai/InvokeAI · error

No existing parent found for {path}

Error message

No existing parent found for {path}

What it means

_nearest_existing_parent walks up a path's parents looking for an existing ancestor to stat for filesystem comparison. If it reaches the filesystem root (current.parent == current) without finding an existing directory, it raises FileNotFoundError('No existing parent found for {path}').

Source

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

        current = start.resolve()
        while current != root and current.is_relative_to(root):
            try:
                current.rmdir()
            except OSError:
                return
            current = current.parent

    def _assert_same_filesystem(self, source: Path, destination: Path) -> None:
        source_parent = source.parent
        destination_parent = self._nearest_existing_parent(destination.parent)
        if source_parent.stat().st_dev != destination_parent.stat().st_dev:
            raise ValueError(f"Cross-filesystem image move is not supported: {source} -> {destination}")

    def _nearest_existing_parent(self, path: Path) -> Path:
        current = path
        while not current.exists():
            if current.parent == current:
                raise FileNotFoundError(f"No existing parent found for {path}")
            current = current.parent
        return current

    def _fsync_file(self, path: Path) -> None:
        try:
            with path.open("rb") as file:
                os.fsync(file.fileno())
        except OSError as e:
            self._logger.debug("Unable to fsync file: %s: %s", path, e)

    def _fsync_dir(self, path: Path) -> None:
        try:
            dir_fd = os.open(path, os.O_RDONLY)
        except OSError as e:
            self._logger.debug("Unable to open directory for fsync: %s: %s", path, e)
            return
        try:
            os.fsync(dir_fd)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Ensure the destination path is absolute and its ancestors are valid on the host filesystem.
  2. Create the destination parent directory (mkdir -p) or fix the configured output path before running preflight_moves.
  3. Check for misconfigured environment variables or settings producing empty/relative paths (e.g. INVOKEAI_ROOT unset).
  4. If the path is genuinely unreachable, it's a filesystem/OS-level issue — verify mounts and permissions.

Example fix

// before
dest = "" or "outputs/x"  # unresolvable relative/empty path
// after
from pathlib import Path
dest = Path(invokeai_root) / "images" / "new-sub"
dest.parent.mkdir(parents=True, exist_ok=True)
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
def destination_is_resolvable(dest: Path) -> bool:
    d = Path(dest).resolve()
    return any(p.exists() for p in [d, *d.parents])

Type guard

def is_absolute_existing_rooted(path: Path) -> bool:
    return path.is_absolute() and any(p.exists() for p in [path, *path.parents])

Try / catch

try:
    service.preflight_moves(job_id)
except FileNotFoundError as e:
    if "No existing parent found" in str(e):
        # fix the destination path config, create parents, re-run

Prevention

When it happens

Trigger: _assert_same_filesystem called with a destination whose entire parent chain doesn't exist — only possible with a malformed path (e.g. an unresolvable/rooted relative path), since even '/' normally exists. Typically a bug in path construction or a mocked/broken filesystem in tests.

Common situations: Passing an empty or relative path fragment as destination; a destination string with a bad mount prefix; sandboxed test environments where root doesn't exist; typos producing paths like 'images/outputs' resolved from a nonexistent cwd.

Related errors


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