t8y2/dbx · error · FileNotFoundError

{path}

Error message

{path}

What it means

required_path raises FileNotFoundError(path) when the variable is set but the resolved path is not an existing regular file. The bare path is used as the exception message. This catches stale or wrong artifact paths.

Source

Thrown at agents/drivers/argo-go/bench/agent_compare.py:621

def percentile(values: list[float], fraction: float) -> float:
    if not values:
        return 0.0
    index = min(len(values) - 1, max(0, round((len(values) - 1) * fraction)))
    return values[index]


def elapsed_ms(started: float) -> float:
    return (time.perf_counter() - started) * 1000


def required_path(name: str) -> Path:
    value = os.getenv(name, "")
    if not value:
        raise ValueError(f"{name} is required")
    path = Path(value).expanduser().resolve()
    if not path.is_file():
        raise FileNotFoundError(path)
    return path


def env_default(name: str, fallback: str) -> str:
    return os.getenv(name, "") or fallback


def env_int(name: str, fallback: int) -> int:
    value = int(env_default(name, str(fallback)))
    if value < 1:
        raise ValueError(f"{name} must be positive")
    return value


def env_int_list(name: str, fallback: list[int]) -> list[int]:
    raw = os.getenv(name, "")
    values = fallback if not raw else [int(value.strip()) for value in raw.split(",")]
    if not values or any(value < 1 for value in values):

View on GitHub (pinned to c0390bff16)

Solutions

  1. Build the artifact first (go build / mvn package) so the file exists at the configured path
  2. Correct the env var to the actual file location (note the path is expanduser().resolve()'d, so use an absolute path)
  3. Delete the stale env value and re-export the current artifact path
  4. In CI, add a build-and-verify step that asserts the artifact exists before the bench job

Example fix

// before
export JDBC_JAR=$PWD/target/old-name.jar   # FileNotFoundError
// after
mvn -q package && export JDBC_JAR=$PWD/target/argo-jdbc-1.0.jar
python3 agent_compare.py
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
p = Path(os.getenv("JDBC_JAR", "")).expanduser().resolve()
if not p.is_file():
    raise SystemExit(f"{p} is not a file — build the artifact first")

Try / catch

try:
    artifact = required_path("ARGO_GO_AGENT")
except FileNotFoundError as e:
    sys.exit(f"artifact missing at {e}; run the build step first")

Prevention

When it happens

Trigger: configured_candidates passes an env var whose value points to a directory, a deleted/not-yet-built binary, or a path with a typo/incorrect ~ expansion; the benchmark then aborts before starting any candidate.

Common situations: Forgot to run the build so the agent binary/jar was never produced; artifact moved after a refactor; absolute path from another machine baked into env; relative path resolved from the wrong working directory.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/2d2cf4501ce192f0. Report an issue: GitHub.