calesthio/OpenMontage · error · FileNotFoundError
Image not found: {image_path}
Error message
Image not found: {image_path} What it means
Standard FileNotFoundError raised by image_file_to_raw_base64() in tools/_kling/media.py when the given path does not exist as a regular file (is_file() is false for missing paths and for directories). The offending path is included in the message.
Source
Thrown at tools/_kling/media.py:27
def strip_data_uri_prefix(value: str | None) -> str | None:
"""Return raw base64/content by removing a data URI prefix if present."""
if value is None:
return None
marker = ";base64,"
if value.startswith("data:") and marker in value:
return value.split(marker, 1)[1]
return value
def image_file_to_raw_base64(path: str | Path) -> str:
"""Read a local image file and return raw base64 without data URI prefix."""
image_path = Path(path)
if not image_path.is_file():
raise FileNotFoundError(f"Image not found: {image_path}")
return base64.b64encode(image_path.read_bytes()).decode("ascii")
def file_to_raw_base64(path: str | Path, *, label: str = "File") -> str:
"""Read a local media file and return raw base64 without a data URI prefix."""
media_path = Path(path)
if not media_path.is_file():
raise FileNotFoundError(f"{label} not found: {media_path}")
return base64.b64encode(media_path.read_bytes()).decode("ascii")
def normalize_image_input(url: str | None = None, path: str | Path | None = None) -> str | None:
"""Normalize a Kling image input to either URL or raw base64."""
if url:
return strip_data_uri_prefix(url)
if path:View on GitHub (pinned to 95e1c3d0ab)
Solutions
- Check the path with Path(p).resolve() and confirm it exists from the process's actual cwd
- Use absolute paths, e.g. build them from a known root: BASE_DIR / 'assets' / 'ref.png'
- If you meant to pass a hosted image, use the url= parameter instead of path=
Example fix
// before
b64 = image_file_to_raw_base64('assets/ref.png') # relative, wrong cwd
// after
from pathlib import Path
img = Path('assets/ref.png').resolve()
if not img.is_file():
raise FileNotFoundError(f'expected reference image missing: {img}')
b64 = image_file_to_raw_base64(img) Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
def image_input_ready(path: str) -> bool:
p = Path(path)
return p.is_file() and p.stat().st_size > 0 Try / catch
try:
b64 = image_file_to_raw_base64(path)
except FileNotFoundError as e:
logger.error('reference image missing: %s', e)
raise Prevention
- Resolve paths to absolute before the API call: Path(p).resolve()
- Validate image existence at pipeline preflight, before any cost is incurred
- For hosted images use url=, not path=
When it happens
Trigger: Calling normalize_image_input(path=...) or any function that base64-encodes a local image with a wrong path, a relative path resolved against an unexpected working directory, a directory path, or a file that was moved/deleted after the path was captured.
Common situations: Relative paths ('assets/ref.png') run from a different cwd; typos or wrong extension (.jpg vs .png); temp files cleaned up before the call; passing a URL where a local path was expected.
Related errors
- {label} not found: {media_path}
- Input file not found: {path}
- Input file not found: {path}
- Reference image not found: {ref}
- Image not found: {path}
AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15).
Data as JSON: /api/errors/512d3fd79b088ec1.
Report an issue: GitHub.