HKUDS/Vibe-Trading · error · ValueError

run_id {run_id!r} must be a bare run directory name

Error message

run_id {run_id!r} must be a bare run directory name

What it means

safe_run_id expects a single path component: it rejects blank strings, absolute paths, multi-part names, and '.', '..' components. Anything path-shaped fails fast before filesystem lookup because a run_id maps to a directory name under allowed run roots.

Source

Thrown at agent/src/tools/path_utils.py:392

    Args:
        run_id: Bare run directory name, not a path.

    Returns:
        Existing run directory under one of the allowed run roots.

    Raises:
        ValueError: If the run id is empty, path-shaped, or not found.
    """
    _rejects_unc(run_id)
    candidate = Path(run_id)
    if (
        not run_id.strip()
        or candidate.is_absolute()
        or len(candidate.parts) != 1
        or any(part in {"", ".", ".."} for part in candidate.parts)
    ):
        raise ValueError(f"run_id {run_id!r} must be a bare run directory name")

    roots = _allowed_run_roots()
    for root in roots:
        resolved = (root / candidate.name).resolve()
        if resolved.is_relative_to(root) and resolved.is_dir():
            return resolved

    raise ValueError(
        f"run_id {run_id!r} was not found under allowed run roots.\n"
        f"{_describe_roots(roots)}"
    )

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Pass just the directory name, e.g. run_id='run-42'
  2. Derive it via Path(run_dir).name
  3. Sanitize: reject run_ids containing '/', '\\', or that strip to empty

Example fix

# before
safe_run_id("/var/runs/run-42")
# after
safe_run_id("run-42")
Defensive patterns

Strategy: type-guard

Validate before calling

import re
if not re.fullmatch(r"[^/\\]+", run_id.strip()) or run_id.strip() in {".", ".."}:
    raise ArgumentError("run_id must be a bare directory name")

Type guard

def is_bare_run_id(rid: str) -> bool:
    rid = rid.strip()
    return bool(rid) and not rid.startswith(("/", "\\")) and len(Path(rid).parts) == 1 and rid not in {".", ".."}

Try / catch

try:
    rd = safe_run_id(run_id)
except ValueError as e:
    if "bare run directory name" in str(e):
        rd = safe_run_id(Path(run_id).name)

Prevention

When it happens

Trigger: run_id='runs/run-42', run_id='/abs/path', run_id='', run_id='.', or run_id='run/../run'.

Common situations: Passing a full path where an identifier is expected, or trimming user input to an empty string.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/eaea3f91263df6f5. Report an issue: GitHub.