t8y2/dbx · error · ValueError

{name} must be positive

Error message

{name} must be positive

What it means

env_int reads an integer environment variable and requires it to be strictly positive. If the parsed value is zero or negative it raises ValueError '<name> must be positive'. This guards numeric tuning knobs (iterations, sizes, timeouts) against meaningless or harmful values.

Source

Thrown at agents/drivers/iotdb/bench/run.py:234


def ensure_artifacts() -> None:
    for path in (JDBC_JAR, GO_BINARY):
        if not path.is_file():
            raise FileNotFoundError(path)


def benchmark_order(commands: dict[str, list[str]]) -> list[str]:
    names = [name.strip() for name in os.getenv("BENCH_ORDER", "jdbc,go").split(",") if name.strip()]
    if len(names) != len(commands) or set(names) != set(commands):
        raise ValueError(f"BENCH_ORDER must contain exactly: {','.join(commands)}")
    return names


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


def env_float(name: str, fallback: float) -> float:
    value = float(os.getenv(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
    return raw.strip().lower() in {"1", "true", "yes", "on"}


if __name__ == "__main__":

View on GitHub (pinned to c0390bff16)

Solutions

  1. Set the variable to a positive integer, e.g. SAMPLES=10.
  2. Unset the variable to use the built-in fallback value.
  3. Check the script for which env vars go through env_int and their defaults.
  4. Fix CI/Makefile exports that pass 0 or negative values.

Example fix

# before
SAMPLES=0 python run.py
# after
SAMPLES=10 python run.py
Defensive patterns

Strategy: validation

Validate before calling

import os
raw = os.getenv("SAMPLES", "")
if raw and int(raw) <= 0:
    raise SystemExit("SAMPLES must be a positive integer")

Try / catch

try:
    value = env_int("SAMPLES", 10)
except ValueError as e:
    print(f"bad env var: {e}; using default")
    value = 10

Prevention

When it happens

Trigger: Setting an env var consumed via env_int (called from main) to 0, a negative number, or a value that would default to <= 0 — e.g. SAMPLES=0 or THREADS=-2.

Common situations: Copy-pasting example configs with placeholder zeros; shell quoting mistakes turning values weird; someone 'disabling' a feature by setting its count to 0.

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