{"record":{"id":"63dfafa997ffe073","repo":"harry0703/MoneyPrinterTurbo","slug":"elevenlabs-input-video-does-not-exist","errorCode":null,"errorMessage":"ElevenLabs input video does not exist","messagePattern":"ElevenLabs input video does not exist","errorType":"exception","errorClass":"ElevenLabsMusicError","httpStatus":null,"severity":"error","filePath":"app/services/elevenlabs_music.py","lineNumber":373,"sourceCode":"            \"ElevenLabs background music generated: \"\n            f\"output={output_path}, size={total_bytes} bytes\"\n        )\n        return output_path\n    finally:\n        _remove_file(temp_audio_path)\n\n\ndef generate_bgm(\n    video_path: str,\n    output_path: str,\n    video_duration: float,\n    prompt: str = \"\",\n) -> str:\n    \"\"\"为一条已拼接视频生成时长和画面匹配的 ElevenLabs 背景音乐。\"\"\"\n    if not get_api_key():\n        raise ElevenLabsMusicError(\"ElevenLabs API key is required\")\n    if not os.path.isfile(video_path):\n        raise ElevenLabsMusicError(\"ElevenLabs input video does not exist\")\n    try:\n        duration = float(video_duration)\n    except (TypeError, ValueError) as exc:\n        raise ElevenLabsMusicError(\n            \"ElevenLabs video duration is invalid\"\n        ) from exc\n    if not math.isfinite(duration) or duration <= 0:\n        raise ElevenLabsMusicError(\"ElevenLabs video duration is invalid\")\n    if duration > MAX_VIDEO_DURATION_SECONDS:\n        raise ElevenLabsMusicError(\n            \"ElevenLabs supports videos up to 600 seconds\"\n        )\n    prompt = str(prompt or \"\").strip()\n    if len(prompt) > MAX_PROMPT_LENGTH:\n        raise ElevenLabsMusicError(\n            \"ElevenLabs music prompt exceeds 1000 characters\"\n        )\n","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/app/services/elevenlabs_music.py#L355-L391","documentation":"Guard in generate_bgm: os.path.isfile(video_path) is false — the input video file does not exist (or is a directory). Checked before any network or proxy work so the task fails fast instead of uploading garbage or crashing later in _create_video_proxy.","triggerScenarios":"Calling generate_bgm with a path that was never rendered, was already deleted by a cleanup step, lives on an unmounted volume, or points at a directory.","commonSituations":"Race between a temp-file cleanup and the BGM step in the pipeline, passing a relative path while the process cwd changed, video rendered in a container path not mounted into the worker, or a typo'd path from task config.","solutions":["Verify the concat/render step actually produced the file and that the path passed to generate_bgm is the same absolute path","Use absolute paths (Path(video_path).resolve()) when queueing the BGM job","Check mount points if generation and BGM run in different containers","Add an existence assertion right after the render step to catch deletion races early"],"exampleFix":"# before\ngenerate_bgm(video_path, output_path, duration, prompt)  # path may be stale\n\n# after\nvideo_path = str(Path(video_path).resolve())\nif not os.path.isfile(video_path):\n    raise FileNotFoundError(f\"concatenated video missing before BGM: {video_path}\")\ngenerate_bgm(video_path, output_path, duration, prompt)","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\np = Path(video_path).resolve()\nassert p.is_file(), f\"missing input video: {p}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass absolute resolved paths between pipeline steps","Do not delete render artifacts until all post-processing (BGM/subtitles) completes"],"tags":["filesystem","guard","validation"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}