t8y2/dbx · error · ValueError

{name} must be positive

Error message

{name} must be positive

What it means

env_int reads an environment variable as an integer and raises ValueError('{name} must be positive') when the value is less than 1. Counts, sizes, and iterations for the benchmark must be >= 1, so zero/negative values are rejected.

Source

Thrown at agents/drivers/cassandra-go/bench/agent_compare.py:304

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_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


def env_bool(name: str, fallback: bool) -> bool:
    raw = os.getenv(name)
    if raw is None or raw == "":
        return fallback
    normalized = raw.strip().lower()
    if normalized in {"1", "true", "yes", "on"}:
        return True
    if normalized in {"0", "false", "no", "off"}:

View on GitHub (pinned to c0390bff16)

Solutions

  1. Set the variable to a positive integer, e.g. export BENCH_ITERATIONS=100
  2. Audit `env | grep -i BENCH` for 0/negative values before running
  3. Fix the generating script so the computed value is always >= 1

Example fix

// before
BENCH_ITERATIONS=0 python agent_compare.py
// after
BENCH_ITERATIONS=10 python agent_compare.py
Defensive patterns

Strategy: validation

Validate before calling

def validate_positive_int(name: str) -> int:
    raw = os.getenv(name)
    if raw is None or raw == "":
        raise SystemExit(f"{name} must be set to a positive integer")
    try:
        value = int(raw)
    except ValueError:
        raise SystemExit(f"{name}={raw!r} is not an integer")
    if value < 1:
        raise SystemExit(f"{name}={raw!r} must be >= 1")
    return value

validate_positive_int("BENCH_ITERATIONS")

Type guard

def is_positive_int(raw: str | None) -> bool:
    if raw is None or raw == "":
        return False
    try:
        return int(raw) >= 1
    except ValueError:
        return False

Prevention

When it happens

Trigger: Calling env_int (from main, connection_params, or configured_workloads) with an env var set to '0', '-3', or another integer below 1.

Common situations: Setting a count to 0 intending 'unlimited' or 'skip'; arithmetic in a wrapper script producing a negative; typo in a CI matrix value.

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/3b3e9a736ed3259e. Report an issue: GitHub.