{"record":{"id":"3419fb43e1a58c08","repo":"calesthio/OpenMontage","slug":"input-file-not-found-path-3419fb","errorCode":null,"errorMessage":"Input file not found: {path}","messagePattern":"Input file not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"tools/video/grok_video.py","lineNumber":33,"sourceCode":"\nfrom tools.base_tool import (\n    BaseTool,\n    Determinism,\n    ExecutionMode,\n    ResourceProfile,\n    RetryPolicy,\n    ToolResult,\n    ToolRuntime,\n    ToolStability,\n    ToolStatus,\n    ToolTier,\n)\n\n\ndef _file_to_data_uri(path_str: str) -> str:\n    path = Path(path_str)\n    if not path.exists():\n        raise FileNotFoundError(f\"Input file not found: {path}\")\n    mime_type, _ = mimetypes.guess_type(path.name)\n    if not mime_type:\n        mime_type = \"application/octet-stream\"\n    encoded = base64.b64encode(path.read_bytes()).decode(\"ascii\")\n    return f\"data:{mime_type};base64,{encoded}\"\n\n\ndef _normalize_media_ref(url_value: str | None, path_value: str | None) -> dict[str, str] | None:\n    if url_value:\n        return {\"url\": url_value}\n    if path_value:\n        return {\"url\": _file_to_data_uri(path_value)}\n    return None\n\n\nclass GrokVideo(BaseTool):\n    name = \"grok_video\"\n    version = \"0.1.0\"","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/grok_video.py#L15-L51","documentation":"Raised by _file_to_data_uri in the Grok video tool when a supplied local file path does not exist. The helper converts local media to a base64 data: URI for the xAI API; it checks Path.exists() first and raises FileNotFoundError with the exact path so the caller can see what was missing.","triggerScenarios":"Any grok_video operation that receives image_path or reference_image_paths (image_to_video, reference_to_video): the referenced file is absent at that location when the payload is built, before any network call is made.","commonSituations":"Relative paths resolved against a different working directory; typos in the path; files cleaned up by an earlier pipeline stage; paths from another machine/environment; race where a preceding render step has not written the file yet.","solutions":["Check the path in the error message exists (ls) and fix typos or missing directories.","Pass absolute paths instead of relative paths to avoid working-directory ambiguity.","If the file is produced by a prior pipeline stage, verify that stage succeeded before calling grok_video.","Use image_url/reference_image_urls instead when the media is hosted remotely."],"exampleFix":"# before\n{\"operation\": \"image_to_video\", \"image_path\": \"img/frame1.png\"}  # relative, cwd-dependent\n\n# after\n{\"operation\": \"image_to_video\", \"image_path\": \"/abs/path/to/img/frame1.png\"}","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef require_media_file(path_value: str | None, key: str) -> str:\n    if not path_value:\n        raise ValueError(f\"{key} is required\")\n    p = Path(path_value).expanduser().resolve()\n    if not p.is_file():\n        raise FileNotFoundError(f\"{key} file missing: {p}\")\n    return str(p)\n\ninputs[\"image_path\"] = require_media_file(inputs.get(\"image_path\"), \"image_path\")","typeGuard":"from pathlib import Path\n\ndef is_readable_file(v: object) -> bool:\n    return isinstance(v, str) and len(v) > 0 and Path(v).expanduser().resolve().is_file()","tryCatchPattern":"try:\n    result = grok_video(inputs)\nexcept FileNotFoundError as e:\n    # resolve to absolute path and fail loudly — retrying the same path is futile\n    raise MissingAsset(str(e)) from e","preventionTips":["Always pass absolute paths to media inputs.","Assert upstream render stages exit 0 before invoking grok_video.","Validate file existence in your own glue code before building tool inputs."],"tags":["grok","file-not-found","local-file","validation","path"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}