t8y2/dbx · error · ValueError

{name} must be positive

Error message

{name} must be positive

What it means

env_int parses an environment variable as an integer (with fallback default) and enforces a lower bound: values below 1 raise ValueError "{name} must be positive". It protects knobs like page sizes, concurrency, and iteration counts from nonsensical zero/negative values.

Source

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

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):
        raise ValueError(f"{name} must contain positive integers")
    return values


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

View on GitHub (pinned to c0390bff16)

Solutions

  1. Set the variable to an integer >= 1 (e.g. `export BENCH_CONCURRENCY=4`)
  2. Unset the variable to fall back to the built-in default
  3. Check the variable name in the error message and make sure you're tuning the intended knob
  4. Clamp or document values in the wrapper script: `export BENCH_PAGE_SIZE=$(( PAGE < 1 ? 1 : PAGE ))`

Example fix

// before
export BENCH_PAGE_SIZE=0
// after
export BENCH_PAGE_SIZE=100
Defensive patterns

Strategy: validation

Validate before calling

import os
v = os.getenv("BENCH_CONCURRENCY", "")
if v and (not v.lstrip('-').isdigit() or int(v) < 1):
    raise SystemExit(f"BENCH_CONCURRENCY={v!r} must be a positive integer")

Try / catch

try:
    n = env_int("BENCH_CONCURRENCY", 4)
except ValueError as e:
    sys.exit(f"bad env value: {e}")

Prevention

When it happens

Trigger: Exporting any env var read via env_int (called from main, connection_params, configured_workloads, query_workload, benchmark_concurrency, probe_candidate — e.g. BENCH_PAGE_SIZE, BENCH_CONCURRENCY) with 0, a negative number, or a non-numeric string that int() coerces oddly (int() on non-numeric actually raises its own ValueError, but 0/-1 hits this check).

Common situations: `export BENCH_CONCURRENCY=0` intending "unlimited"; negative value copied from docs of another tool; empty-string intent that env_default replaced with a wrong default; shell var set as `0` for a boolean-style flag.

Understand the failure class

Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.

Related errors


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