{"record":{"id":"e320ba2e73efcc11","repo":"harry0703/MoneyPrinterTurbo","slug":"elevenlabs-local-file-operation-failed-exc","errorCode":null,"errorMessage":"ElevenLabs local file operation failed: {exc}","messagePattern":"ElevenLabs local file operation failed: (.+?)","errorType":"exception","errorClass":"ElevenLabsMusicError","httpStatus":null,"severity":"error","filePath":"app/services/elevenlabs_music.py","lineNumber":399,"sourceCode":"        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\n    proxy_path = \"\"\n    try:\n        proxy_path = _create_video_proxy(video_path)\n        return _request_bgm(proxy_path, output_path, prompt)\n    except ElevenLabsMusicError:\n        raise\n    except OSError as exc:\n        raise ElevenLabsMusicError(\n            f\"ElevenLabs local file operation failed: {exc}\"\n        ) from exc\n    finally:\n        _remove_file(proxy_path)\n","sourceCodeStart":381,"sourceCodeEnd":404,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/app/services/elevenlabs_music.py#L381-L404","documentation":"Catch-all in generate_bgm for OSError raised outside the HTTP call — i.e. during _create_video_proxy (FFmpeg re-encode to a <=200MB proxy) or file moves. ElevenLabsMusicError is re-raised untouched; only raw OS-level failures get wrapped with the underlying exc text.","triggerScenarios":"FFmpeg subprocess spawn fails (binary not found), the proxy write hits ENOSPC (disk full), permission errors on temp/output directories, or os.replace across filesystems raising OSError.","commonSituations":"ffmpeg/ffprobe not installed or not on PATH in docker images, /tmp too small for a 200MB proxy of a long video, read-only output volume, or temp dir and output dir on different mounts.","solutions":["Check the embedded exc text: 'No such file or directory' with a subprocess usually means the ffmpeg binary is missing — install it or fix PATH","Free space or point TMPDIR at a volume large enough for the proxy (up to 200MB) plus audio output","Ensure output_path and temp dirs are on writable mounts","Keep temp and output on the same filesystem so os.replace stays atomic"],"exampleFix":"# before\nproxy_path = _create_video_proxy(video_path)  # ENOSPC mid-encode, opaque\n\n# after\nimport shutil\nif shutil.disk_usage(tempfile.gettempdir()).free < 500 * 1024 * 1024:\n    raise OSError(f\"insufficient temp space for proxy: {tempfile.gettempdir()}\")\nproxy_path = _create_video_proxy(video_path)","handlingStrategy":"validation","validationCode":"import shutil\n\nassert shutil.which(\"ffmpeg\"), \"ffmpeg binary required for proxy creation\"\nassert os.access(os.path.dirname(output_path) or \".\", os.W_OK)","typeGuard":null,"tryCatchPattern":"try:\n    elm.generate_bgm(...)\nexcept elm.ElevenLabsMusicError as e:\n    if \"local file operation\" in str(e):\n        check_disk_and_paths()  # surface ENOSPC/permission detail to ops\n    raise","preventionTips":["Install ffmpeg in the runtime image and keep PATH stable","Ensure temp dir has >=200MB free per job","Keep temp and output dirs on the same filesystem"],"tags":["ffmpeg","filesystem","os-error"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}