{"record":{"id":"728960b71777ffc2","repo":"harry0703/MoneyPrinterTurbo","slug":"description-file-does-not-exist-raw-path","errorCode":null,"errorMessage":"{description} file does not exist: {raw_path}","messagePattern":"(.+?) file does not exist: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"cli.py","lineNumber":603,"sourceCode":"    本地素材旧版本始终相对 ``storage/local_videos`` 解析。为兼容已有脚本，\n    当前目录找不到相对路径时允许回退该目录；绝对路径始终按用户输入\n    直接解析。\n    \"\"\"\n    expanded_path = os.path.expanduser(raw_path.strip())\n    if not expanded_path:\n        raise ValueError(f\"{description} path cannot be empty\")\n\n    candidate = (\n        expanded_path\n        if os.path.isabs(expanded_path)\n        else os.path.join(os.getcwd(), expanded_path)\n    )\n    resolved_path = os.path.realpath(candidate)\n    if not os.path.isfile(resolved_path) and fallback_dir and not os.path.isabs(expanded_path):\n        resolved_path = os.path.realpath(os.path.join(fallback_dir, expanded_path))\n\n    if not os.path.isfile(resolved_path):\n        raise ValueError(f\"{description} file does not exist: {raw_path}\")\n    return resolved_path\n\n\ndef _path_is_within_directory(file_path: str, directory: str) -> bool:\n    try:\n        return os.path.commonpath(\n            [os.path.realpath(directory), os.path.realpath(file_path)]\n        ) == os.path.realpath(directory)\n    except ValueError:\n        # Windows 不同盘符无法计算 commonpath，此时文件显然不在目标目录内。\n        return False\n\n\ndef _resolve_managed_resource_file(\n    raw_path: str,\n    *,\n    resource_dir: str,\n    description: str,","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/cli.py#L585-L621","documentation":"Raised by the CLI file resolver when the candidate path is neither an existing file from the current working directory nor (for relative paths) inside the legacy fallback directory storage/local_videos. Absolute paths are taken as-is, so a wrong absolute path fails here too.","triggerScenarios":"Running the CLI from a directory where the relative file does not exist AND the file is also not under storage/local_videos; passing an absolute path to a moved/deleted file; typo in the filename; wrong cwd when invoking the command.","commonSituations":"User runs the command from a different directory than where the input lives; file was renamed or moved after being recorded in a script; older scripts referencing storage/local_videos assets that were cleaned.","solutions":["Check the file exists at the path you passed: ls <path> from the same directory you run the CLI in.","Use an absolute path to remove cwd ambiguity, or cd into the directory containing the file.","For legacy local materials, place the file under storage/local_videos and pass the bare filename."],"exampleFix":"# before (run from /home/user)\npython cli.py --file intro.mp4  # file actually in /home/user/videos\n\n# after\npython cli.py --file /home/user/videos/intro.mp4  # or: cd /home/user/videos && python cli.py --file intro.mp4","handlingStrategy":"validation","validationCode":"import os\nfrom pathlib import Path\n\ndef resolves_existing(raw: str, fallback_dir: str | None) -> bool:\n    expanded = os.path.expanduser(raw.strip())\n    if not expanded:\n        return False\n    cand = expanded if os.path.isabs(expanded) else os.path.join(os.getcwd(), expanded)\n    if os.path.isfile(os.path.realpath(cand)):\n        return True\n    return bool(fallback_dir and not os.path.isabs(expanded)\n                and os.path.isfile(os.path.realpath(os.path.join(fallback_dir, expanded))))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass absolute paths in scripts to remove cwd dependence.","Keep legacy local materials under storage/local_videos so the fallback finds them."],"tags":["cli","file-not-found","path"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}