usestrix/strix · error · ValueError

Failed to read target list file '{path_str}': {e!s}

Error message

Failed to read target list file '{path_str}': {e!s}

What it means

Catch-all for OSError raised while reading the target list file (after existence was confirmed) — permission errors, files deleted between the is_file() check and the read, or I/O failures on flaky mounts. The original OSError is chained as the cause, so the message includes the OS-level detail.

Source

Thrown at strix/interface/utils.py:1227

def read_target_list_file(path_str: str) -> list[str]:
    """Read scan targets from a file, one target per non-empty, non-comment line."""
    if not path_str or not path_str.strip():
        raise ValueError("--target-list path must not be empty.")

    path = Path(path_str).expanduser()
    if not path.is_file():
        raise ValueError(f"Target list file '{path_str}' is not an existing file.")

    try:
        targets = [
            target
            for line in path.read_text(encoding="utf-8").splitlines()
            if (target := line.strip()) and not target.startswith("#")
        ]
    except UnicodeDecodeError as e:
        raise ValueError(f"Target list file '{path_str}' must be valid UTF-8 text: {e!s}") from e
    except OSError as e:
        raise ValueError(f"Failed to read target list file '{path_str}': {e!s}") from e

    targets = [target for target in targets if target]
    if not targets:
        raise ValueError(f"Target list file '{path_str}' is empty.")
    return targets


def sanitize_name(name: str) -> str:
    sanitized = re.sub(r"[^A-Za-z0-9._-]", "-", name.strip())
    return sanitized or "target"


def derive_repo_base_name(repo_url: str) -> str:
    if repo_url.endswith("/"):
        repo_url = repo_url[:-1]

    if ":" in repo_url and repo_url.startswith("git@"):
        path_part = repo_url.split(":", 1)[1]

View on GitHub (pinned to 8551339130)

Solutions

  1. Inspect the chained cause in the traceback for the OS errno.
  2. Fix permissions: chmod 644 targets.txt and ensure the parent dir is traversable.
  3. Move the list to local disk if it sits on an unreliable network mount.
Defensive patterns

Strategy: try-catch

Validate before calling

import os

def is_readable_file(p: str) -> bool:
    try:
        with open(p, encoding="utf-8"):
            return True
    except OSError:
        return False

if not is_readable_file(path_str):
    raise SystemExit(f"Cannot read {path_str}: check permissions and mounts")

Try / catch

try:
    targets = read_target_list_file(path_str)
except ValueError as e:
    if "Failed to read target list file" in str(e):
        raise SystemExit(f"OS error reading {path_str}: {e.__cause__}") from e
    raise

Prevention

When it happens

Trigger: read_target_list_file succeeds the is_file() check, then path.read_text raises PermissionError (mode 000 file), or the containing directory loses read/execute permission, or the network share drops mid-read.

Common situations: Files owned by another user in shared CI runners; security software locking the file; race with a concurrent process deleting the list.

Related errors


AI-assisted analysis of usestrix/strix@8551339130 (2026-08-15). Data as JSON: /api/errors/7fde9fb5e67cc82a. Report an issue: GitHub.