{"record":{"id":"adda6999743d8afd","repo":"calesthio/OpenMontage","slug":"reference-image-not-found-path","errorCode":null,"errorMessage":"Reference image not found: {path}","messagePattern":"Reference image not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"tools/video/gemini_omni_video.py","lineNumber":210,"sourceCode":"        raw = str(inputs.get(\"duration\") or _DEFAULT_DURATION_SECONDS).strip().lower()\n        raw = raw[:-1] if raw.endswith(\"s\") else raw\n        try:\n            seconds = int(float(raw))\n        except ValueError:\n            seconds = _DEFAULT_DURATION_SECONDS\n        return max(3, min(10, seconds))\n\n    def estimate_cost(self, inputs: dict[str, Any]) -> float:\n        return _COST_PER_SECOND * self._duration_hint(inputs)\n\n    def estimate_runtime(self, inputs: dict[str, Any]) -> float:\n        return 180.0\n\n    @staticmethod\n    def _image_part(path_str: str) -> dict[str, Any]:\n        path = Path(path_str)\n        if not path.exists():\n            raise FileNotFoundError(f\"Reference image not found: {path}\")\n        mime_type, _ = mimetypes.guess_type(path.name)\n        if not mime_type or not mime_type.startswith(\"image/\"):\n            mime_type = \"image/png\"\n        return {\n            \"type\": \"image\",\n            \"data\": base64.b64encode(path.read_bytes()).decode(\"ascii\"),\n            \"mime_type\": mime_type,\n        }\n\n    def _upload_video_file(self, requests_mod: Any, api_key: str, path_str: str) -> str:\n        \"\"\"Upload a local video via the Files API (resumable) and return its URI.\"\"\"\n        path = Path(path_str)\n        if not path.exists():\n            raise FileNotFoundError(f\"Input video not found: {path}\")\n        mime_type, _ = mimetypes.guess_type(path.name)\n        if not mime_type or not mime_type.startswith(\"video/\"):\n            mime_type = \"video/mp4\"\n        video_bytes = path.read_bytes()","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/gemini_omni_video.py#L192-L228","documentation":"Raised as FileNotFoundError by GeminiOmniVideoTool._image_part when the local reference-image path does not exist on disk (Path.exists() is false) before it is base64-encoded into the request part.","triggerScenarios":"Passing an image_path that is misspelled, relative to a different working directory, or already moved/deleted; a path produced by a prior render step that failed or wrote elsewhere; leading/trailing whitespace or quotes in the path string.","commonSituations":"Long pipelines where an intermediate step cleans its temp dir; running the tool from a different cwd so a relative path no longer resolves; paths assembled from user input without normalization.","solutions":["Check the path exists and is readable before the call (os.path.exists / pathlib)","Use absolute paths (resolve with Path(...).resolve()) so cwd changes cannot break resolution","If the image was supposed to come from an earlier step, verify that step's output path before invoking gemini_omni_video"],"exampleFix":"# before\ninputs = {'prompt':'...','image_path':'tmp/ref.png'}  # cwd moved\n\n# after\nfrom pathlib import Path\nimg = Path('tmp/ref.png').resolve()\nassert img.is_file(), f'missing {img}'\ninputs = {'prompt':'...','image_path':str(img)}","handlingStrategy":"validation","validationCode":"from pathlib import Path\np = Path(image_path).expanduser().resolve()\nif not p.is_file():\n    raise FileNotFoundError(f'reference image missing: {p}')\ninputs['image_path'] = str(p)","typeGuard":"def image_ready(path_str: str) -> bool:\n    p = Path(path_str).expanduser()\n    return p.is_file() and p.stat().st_size > 0","tryCatchPattern":"try:\n    result = gemini_omni_video.run(inputs=inputs)\nexcept FileNotFoundError as e:\n    raise SystemExit(f'fix the image path: {e}') from e","preventionTips":["Resolve to absolute paths at pipeline start so cwd changes cannot break them","Verify intermediate render/download steps produced their outputs before consuming them","Expand ~ and strip user-supplied whitespace/quotes from paths"],"tags":["gemini","file-not-found","video-generation","validation"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}