t8y2/dbx · error · ValueError
{name} must be a boolean
Error message
{name} must be a boolean What it means
env_bool parses an environment variable as a boolean but throws ValueError when the value is not one of the accepted truthy/falsy tokens (1/true/yes/on or 0/false/no/off, case-insensitive). The library fails fast rather than guessing a value for boolean flags.
Source
Thrown at agents/drivers/argo-go/bench/agent_compare.py:660
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"}:
return False
raise ValueError(f"{name} must be a boolean")
if __name__ == "__main__":
main()
View on GitHub (pinned to c0390bff16)
Solutions
- Change the variable to one of: 1, true, yes, on, 0, false, no, off (any case)
- Or unset the variable entirely so the fallback is used
- Grep shell profiles/CI config for the variable name and normalize the value
Example fix
// before export BENCH_TLS=enabled // after export BENCH_TLS=true
Defensive patterns
Strategy: validation
Validate before calling
def validate_bool_env(name: str) -> bool:
raw = (os.getenv(name) or "").strip().lower()
if raw in {"1", "true", "yes", "on"}:
return True
if raw in {"0", "false", "no", "off", ""}:
return False
raise SystemExit(f"{name}={raw!r} must be one of 1/true/yes/on or 0/false/no/off")
validate_bool_env("BENCH_TLS") Type guard
def is_bool_token(raw: str | None) -> bool:
return (raw or "").strip().lower() in {"1", "true", "yes", "on", "0", "false", "no", "off"} Try / catch
try:
params = connection_params()
except ValueError as exc:
if "must be a boolean" in str(exc):
sys.exit(f"fix the boolean env var: {exc}")
raise Prevention
- Stick to canonical true/false for boolean env vars across all tooling
- Document accepted boolean tokens next to each flag in your run scripts
- Add a config lint step that checks boolean vars against the accepted set
When it happens
Trigger: Setting a boolean env var consumed by connection_params to an unrecognized string, e.g. BENCH_TLS=maybe or BENCH_TLS=enabled, then invoking connection_params.
Common situations: Typing 'True ' with stray whitespace is handled, but values like 'y', 'enabled', 'ja', or a translated word are not; copy-pasted config from another tool with different boolean conventions.
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} is required
- {path}
- {name} must be positive
- {name} must be a boolean
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/1010069afd758c73.
Report an issue: GitHub.