{"record":{"id":"e98a6070c7dce757","repo":"ATH-MaaS/Pixelle-Video","slug":"image-path-e98a60","errorCode":null,"errorMessage":"输入图片不存在: {image_path}","messagePattern":"输入图片不存在: (.+?)","errorType":"validation","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/api_services/video_kling.py","lineNumber":182,"sourceCode":"    ) -> str:\n        \"\"\"提交文生视频或图生视频任务。\n\n        Args:\n            image_path: 本地图片路径；为空时调用文生视频接口\n            prompt: 正向提示词（≤2500字符）\n            negative_prompt: 负向提示词（≤2500字符）\n            model_name: 可灵模型名 (kling-v3 / kling-v2-6 / kling-v2-5-turbo)\n            mode: 生成模式 std (标准) / pro (高品质)\n            duration: 视频时长，v3: \"3\"~\"15\", v2: \"5\"或\"10\"\n            cfg_scale: 自由度 [0,1]，越大越贴合提示词\n            sound: 是否生成声音 \"on\"/\"off\"\n            aspect_ratio: 文生视频画幅比例\n\n        Returns:\n            task_id: 任务 ID\n        \"\"\"\n        if image_path and not os.path.exists(image_path):\n            raise FileNotFoundError(f\"输入图片不存在: {image_path}\")\n\n        # 根据模型系列确定 duration 范围\n        model_lower = model_name.lower()\n        is_v3 = \"v3\" in model_lower or \"video-o1\" in model_lower\n        is_v26 = any(tag in model_lower for tag in (\"v2-6\", \"v2.6\"))\n\n        if is_v3:\n            # v3 系列支持 3~15s\n            clamped = str(min(max(int(duration), 3), 15))\n        else:\n            # v2 系列仅支持 5 或 10\n            clamped = \"10\" if int(duration) >= 8 else \"5\"\n\n        body = {\n            \"model_name\": model_name,\n            \"mode\": mode,\n            \"duration\": clamped,\n        }","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/api_services/video_kling.py#L164-L200","documentation":"KlingVideoClient._submit_task validates the image_path argument before building the image2video request. If a path was supplied but the file does not exist on disk, it raises FileNotFoundError immediately, before any network call.","triggerScenarios":"generate_video -> _submit_task called with a non-None image_path where os.path.exists(image_path) is False (video_kling.py:181-182) — e.g. a relative path resolved from the wrong working directory, a deleted temp file, or a typo in the filename/extension.","commonSituations":"Passing a relative path while the process CWD differs from the script directory, using a path downloaded earlier but cleaned up, Windows vs POSIX path separators embedded in config, or building the path with an uninitialized variable ('None' string, empty upload).","solutions":["Print os.path.abspath(image_path) and verify that exact file exists before calling generate_video.","Fix the CWD mismatch: use absolute paths or os.path.join(BASE_DIR, ...) when constructing image_path.","Confirm the image download/previous pipeline step actually succeeded and the file was not deleted by a cleanup job.","If you intend text-to-video, pass image_path=None instead of a bogus path so the client uses the text2video endpoint."],"exampleFix":"# before\nclient.generate_video(image_path=\"assets/input.jpg\", prompt=\"...\")  # FileNotFoundError\n# after\nimport os\nimg = os.path.abspath(\"assets/input.jpg\")\nassert os.path.exists(img), f\"missing image: {img}\"\nclient.generate_video(image_path=img, prompt=\"...\")","handlingStrategy":"validation","validationCode":"import os\nimage_path = os.path.abspath(image_path)\nif image_path and not os.path.isfile(image_path):\n    raise FileNotFoundError(f\"输入图片不存在: {image_path}\")  # 提交前自行校验","typeGuard":"def image_exists(path: str | None) -> bool:\n    return bool(path) and os.path.isfile(os.path.expanduser(path))","tryCatchPattern":"try:\n    url = client.generate_video(image_path=img, ...)\nexcept FileNotFoundError as e:\n    logger.warning(f\"图片缺失，回退为文生视频: {e}\")\n    url = client.generate_video(image_path=None, prompt=prompt, ...)","preventionTips":["Always construct image paths with os.path.abspath / os.path.join(BASE_DIR, ...)","Check os.path.isfile before every call and fail fast in your own code","Avoid temp-file cleanups between image creation and submission","Pass image_path=None when you intend text-to-video instead of a stale path"],"tags":["file-not-found","input-validation","kling","path"],"backgroundTag":"file-not-found","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}