t8y2/dbx · error · ValueError

{name} must contain positive integers

Error message

{name} must contain positive integers

What it means

env_int_list parses a comma-separated integer list from an environment variable; it raises ValueError if the parsed list is empty or any element is below 1, requiring at least one positive integer. Used by main for lists like page sizes or concurrency levels to sweep.

Source

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

    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


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 a comma-separated list of positive integers, e.g. `export BENCH_PAGE_SIZES=10,50,100`
  2. Remove empty segments and trailing commas from the value
  3. Unset the variable to use the fallback list defined in main()
  4. Pre-validate in a wrapper: filter out non-positive entries before export

Example fix

// before
export BENCH_PAGE_SIZES=10,,100
// after
export BENCH_PAGE_SIZES=10,50,100
Defensive patterns

Strategy: validation

Validate before calling

import os
raw = os.getenv("BENCH_PAGE_SIZES", "")
if raw:
    parts = [x.strip() for x in raw.split(",")]
    if any(not p or not p.isdigit() or int(p) < 1 for p in parts):
        raise SystemExit(f"BENCH_PAGE_SIZES={raw!r} must be comma-separated positive integers")

Try / catch

try:
    sizes = env_int_list("BENCH_PAGE_SIZES", [10, 100])
except ValueError as e:
    sys.exit(f"bad env value: {e}")

Prevention

When it happens

Trigger: Setting the variable to "", only commas (",,", yielding empty/failed parses), 0, negative numbers, or whitespace-only segments — e.g. `BENCH_PAGE_SIZES=10,0,100` or `BENCH_PAGE_SIZES=` — then running main().

Common situations: Trailing comma in a copy-pasted list producing an empty final element; user tried to express "default" with 0; spaces around commas are tolerated by strip but blank entries still fail; list intended for a float knob pasted into an int list var.

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/21c2565b010ba9a5. Report an issue: GitHub.