harry0703/MoneyPrinterTurbo · warning · ValueError

file does not exist

Error message

file does not exist

What it means

Final check of resolve_path_within_directory: the path is inside the allowed directory and require_file is True (the default), but os.path.isfile reports the resolved path is not an existing regular file — it may be missing, a directory, or a special file.

Solutions

  1. Confirm the task reached the stage that produces this file before requesting it (check task status first).
  2. Verify the filename against the task record — copy the exact name the server returned, don't construct it.
  3. If files were pruned, re-run the task or restore the artifacts.
  4. Pass require_file=False only when you intentionally resolve a not-yet-created output path.

Example fix

# before
resolve_path_within_directory(task_dir, "final_video.mp4")  # not generated yet

# after
# resolve an output path that will be created later
resolve_path_within_directory(task_dir, "final_video.mp4", require_file=False)
Defensive patterns

Strategy: validation

Validate before calling

import os
expected = os.path.join(base_dir, unsafe_path)
if require_file and not os.path.isfile(expected):
    # file not generated yet — wait or check task status first
    poll_task_status_before_download()

Try / catch

try:
    resolved = resolve_path_within_directory(task_dir, filename)
except ValueError as exc:
    if "file does not exist" in str(exc):
        return HTTP 404 with a retry-after hint
    if "outside the allowed directory" in str(exc):
        return HTTP 403 and log
    raise

Prevention

When it happens

Trigger: Requesting a task artifact that has not been generated yet or was deleted; passing a directory path; referencing a file whose generation step failed earlier; typo in the filename portion.

Common situations: Client polls for a video/audio file before the task finished generating it; task artifacts cleaned up by retention jobs; downloading a still-running task's output.

Related errors


AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14). Data as JSON: /api/errors/883a41e51fad9845. Report an issue: GitHub.

Appendix: source

Thrown at app/utils/file_security.py:33

        raise ValueError("empty path is not allowed")

    base_dir_real = os.path.realpath(base_dir)
    candidate_path = unsafe_path
    if not os.path.isabs(candidate_path):
        candidate_path = os.path.join(base_dir_real, candidate_path)

    resolved_path = os.path.realpath(candidate_path)
    try:
        common_path = os.path.commonpath([base_dir_real, resolved_path])
    except ValueError as exc:
        # Windows 下不同盘符会触发 ValueError,这类路径一定不属于允许目录。
        raise ValueError("path is outside the allowed directory") from exc

    if common_path != base_dir_real:
        raise ValueError("path is outside the allowed directory")

    if require_file and not os.path.isfile(resolved_path):
        raise ValueError("file does not exist")

    return resolved_path

View on GitHub (pinned to 1f9f19c202)