calesthio/OpenMontage · error · FileNotFoundError

Local reference image not found: {path}

Error message

Local reference image not found: {path}

What it means

Raised by the inline helper _get_image_data in google_music when the caller supplies a local reference-image path for image-to-music but that path does not exist on disk. The helper checks os.path.exists before reading bytes for base64-encoding into the Lyria request.

Source

Thrown at tools/audio/google_music.py:203

                import logging

                logging.getLogger(__name__).warning(
                    "Lyria 3 Pro supports up to 184 seconds of audio. Coercing duration_seconds to 184."
                )
                duration = 184.0
            else:
                return ToolResult(
                    success=False,
                    error="lyria-3-pro-preview maximum duration is 184 seconds.",
                )

        # Helper to load reference image bytes + mime type
        def _get_image_data(
            url: str | None, path: str | None
        ) -> tuple[str, str] | None:
            if path:
                if not os.path.exists(path):
                    raise FileNotFoundError(f"Local reference image not found: {path}")
                img_bytes = Path(path).read_bytes()
                mime, _ = mimetypes.guess_type(path)
                if not mime:
                    mime = "image/png"
                b64 = base64.b64encode(img_bytes).decode("utf-8")
                return b64, mime
            if url:
                resp = requests.get(url, timeout=30)
                resp.raise_for_status()
                mime = resp.headers.get("Content-Type")
                if not mime or "image" not in mime:
                    mime = "image/png"
                b64 = base64.b64encode(resp.content).decode("utf-8")
                return b64, mime
            return None

        # Build payload input incorporating target duration instructions
        timed_prompt = f"{prompt}\n\n[Target Duration: {int(duration)} seconds]"

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Verify the file exists and convert to an absolute path before calling the tool
  2. Check earlier pipeline stages actually produced the reference image
  3. In containers, confirm the path is inside a mounted volume

Example fix

// before
inputs = {"prompt": "...", "reference_image_path": "assets/ref.png"}

// after
import os
p = os.path.abspath("assets/ref.png")
assert os.path.exists(p), f"missing reference image: {p}"
inputs = {"prompt": "...", "reference_image_path": p}
Defensive patterns

Strategy: validation

Validate before calling

import os
path = inputs.get("reference_image_path")
if path and not os.path.isfile(os.path.abspath(path)):
    raise FileNotFoundError(f"reference image missing: {path}")

Try / catch

try:
    result = google_music_tool.execute(inputs)
except FileNotFoundError as e:
    # fall back to text-only music generation
    inputs.pop("reference_image_path", None)
    result = google_music_tool.execute(inputs)

Prevention

When it happens

Trigger: Passing reference_image_path that is a relative path resolved against the wrong working directory, a typo, or a file produced by an earlier pipeline step that did not run.

Common situations: Relative paths when the process cwd differs from the project root; multi-stage pipelines where the image-generation step failed silently before music generation; containerized runs where the path was not mounted.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/77b9d854e3daae20. Report an issue: GitHub.