harry0703/MoneyPrinterTurbo · warning · ValueError

{description} path cannot be empty

Error message

{description} path cannot be empty

What it means

CLI helper that turns a file argument into an absolute, verified path: after strip() and expanduser(), an empty string means the user passed a blank --video-file/--audio-file style argument, and it raises ValueError with the parameter description embedded.

Source

Thrown at cli.py:591


def _resolve_cli_file(
    raw_path: str,
    *,
    description: str,
    fallback_dir: str | None = None,
) -> str:
    """
    将 CLI 文件参数按当前工作目录解析为绝对路径,
    并在任务开始前确认存在。

    本地素材旧版本始终相对 ``storage/local_videos`` 解析。为兼容已有脚本,
    当前目录找不到相对路径时允许回退该目录;绝对路径始终按用户输入
    直接解析。
    """
    expanded_path = os.path.expanduser(raw_path.strip())
    if not expanded_path:
        raise ValueError(f"{description} path cannot be empty")

    candidate = (
        expanded_path
        if os.path.isabs(expanded_path)
        else os.path.join(os.getcwd(), expanded_path)
    )
    resolved_path = os.path.realpath(candidate)
    if not os.path.isfile(resolved_path) and fallback_dir and not os.path.isabs(expanded_path):
        resolved_path = os.path.realpath(os.path.join(fallback_dir, expanded_path))

    if not os.path.isfile(resolved_path):
        raise ValueError(f"{description} file does not exist: {raw_path}")
    return resolved_path


def _path_is_within_directory(file_path: str, directory: str) -> bool:
    try:
        return os.path.commonpath(

View on GitHub (pinned to 1f9f19c202)

Solutions

  1. Supply an actual file path for the argument.
  2. In scripts, guard: [ -z "$VIDEO_FILE" ] && { echo 'VIDEO_FILE required'; exit 1; }.
  3. Use parameter defaults like ${VIDEO_FILE:?VIDEO_FILE required} to fail early with a clear message.

Example fix

# before
python cli.py --file ""

# after
python cli.py --file ./input/video1.mp4
Defensive patterns

Strategy: validation

Validate before calling

import os
if not os.path.expanduser((raw_path or "").strip()):
    raise ValueError("file argument must not be empty")

Type guard

def is_nonempty_cli_path(raw: str | None) -> bool:
    return isinstance(raw, str) and bool(os.path.expanduser(raw.strip()))

Prevention

When it happens

Trigger: Running the CLI with an argument that expands to nothing: an empty string, a path of only spaces, or a bare '~' that expanduser leaves in a form the check still catches; shell scripts passing an unset variable ('$UNSET_VAR' expanding to '').

Common situations: Shell script passes "$VIDEO_FILE" when the variable is unset; user quotes an empty string by mistake; config-driven invocation where a field was left blank.

Related errors


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