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 list of integers from an environment variable and requires a non-empty list where every element is >= 1. It raises ValueError when the list is empty or any element is zero/negative.
Source
Thrown at agents/drivers/hive-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
- Set the variable to comma-separated positive integers, e.g. export BENCH_SIZES=100,1000,10000
- Remove zero/negative entries from the list
- Unset the variable to fall back to the built-in default list
- Ensure no empty segments like "100,,200" in the value
Example fix
// before export BENCH_SIZES=100,0,10000 // after export BENCH_SIZES=100,1000,10000
Defensive patterns
Strategy: validation
Validate before calling
def valid_int_list_env(name: str, default: list[int]) -> list[int]:
raw = os.getenv(name, "")
if not raw:
return default
try:
values = [int(v.strip()) for v in raw.split(",") if v.strip()]
except ValueError:
raise SystemExit(f"{name} must be comma-separated integers")
if not values or any(v < 1 for v in values):
raise SystemExit(f"{name} entries must be positive integers")
return values Type guard
def is_positive_int_list(values: list) -> bool:
return bool(values) and all(isinstance(v, int) and v >= 1 for v in values) Try / catch
try:
sizes = env_int_list("BENCH_SIZES", [100, 1000])
except ValueError as e:
print(f"invalid list: {e}; falling back to defaults")
sizes = [100, 1000] Prevention
- Keep list values comma-separated with no trailing commas or empty segments
- Sanity-check list contents with a one-liner before exporting: echo $BENCH_SIZES
- Use defaults by unsetting the variable rather than hand-crafting edge-case lists
- Add unit tests around env parsing helpers with malformed inputs
When it happens
Trigger: Env var parsed by env_int_list (called by main) is set to an empty string after raw was non-empty but splits to empty/whitespace, or contains a value like "0" or "-2", e.g. BENCH_SIZES="100,0"; also fires if raw is "" and the fallback list itself is empty or contains non-positive ints.
Common situations: Trailing commas or whitespace-only entries producing bad splits; someone entering 0 to disable a workload size; malformed lists like ",,".
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
- BENCH_CANDIDATES selected no candidates
- {name} must be positive
- {name} must be positive
- {name} must be a boolean
- {name} must be a boolean
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/e7e3ffb00b46801f.
Report an issue: GitHub.