HKUDS/Vibe-Trading · error · ValueError

run_id {run_id!r} was not found under allowed run roots. {_d

Error message

run_id {run_id!r} was not found under allowed run roots.
{_describe_roots(roots)}

What it means

After safe_run_id validates the bare name, it searches each allowed run root for root/name as an existing directory. If none matches, this 'not found' error with the searched roots is raised.

Source

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

        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. Confirm the directory exists under one of the roots shown in the error
  2. Fix typos / re-derive the id from the run creation response
  3. Re-add the run's parent directory via allowed-run-roots env var

Example fix

# before
safe_run_id("run-9999")  # does not exist
# after
safe_run_id("run-0042")  # actual directory name
Defensive patterns

Strategy: validation

Validate before calling

from agent.src.tools.path_utils import _allowed_run_roots
name = run_id.strip()
exists = any((r / name).is_dir() for r in _allowed_run_roots())
if not exists:
    raise NotFoundError(f"run {name} not found")

Type guard

def run_exists(rid: str) -> bool:
    name = rid.strip()
    return any((r / name).resolve().is_relative_to(r) and (r / name).is_dir() for r in _allowed_run_roots())

Try / catch

try:
    rd = safe_run_id(run_id)
except ValueError as e:
    if "was not found" in str(e):
        runs = list_available_runs(); suggest_closest(run_id, runs)

Prevention

When it happens

Trigger: A correctly formatted run_id whose directory doesn't exist, exists under a non-allowlisted root, or the env var pointing elsewhere.

Common situations: Verifying a run archived/moved after creation, typos in the id, or allowed-run-roots not configured in the current process.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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