{"record":{"id":"2c8180a2b0884707","repo":"t8y2/dbx","slug":"name-must-be-a-boolean-2c8180","errorCode":null,"errorMessage":"{name} must be a boolean","messagePattern":"(.+?) must be a boolean","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agents/drivers/cassandra-go/bench/agent_compare.py","lineNumber":324,"sourceCode":"\n\ndef env_float(name: str, fallback: float) -> float:\n    value = float(env_default(name, str(fallback)))\n    if value <= 0:\n        raise ValueError(f\"{name} must be positive\")\n    return value\n\n\ndef env_bool(name: str, fallback: bool) -> bool:\n    raw = os.getenv(name)\n    if raw is None or raw == \"\":\n        return fallback\n    normalized = raw.strip().lower()\n    if normalized in {\"1\", \"true\", \"yes\", \"on\"}:\n        return True\n    if normalized in {\"0\", \"false\", \"no\", \"off\"}:\n        return False\n    raise ValueError(f\"{name} must be a boolean\")\n\n\nif __name__ == \"__main__\":\n    main()\n","sourceCodeStart":306,"sourceCodeEnd":329,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/cassandra-go/bench/agent_compare.py#L306-L329","documentation":"env_bool parses a boolean environment variable from a restricted set of literals ('1','true','yes','on' vs '0','false','no','off', case-insensitive) and raises ValueError for anything else. The harness deliberately rejects ambiguous spellings like 'True ', 'TRUE', 'enabled', 'y', or '1.0' so behavior is deterministic. Empty/unset falls back to the default, so the error only occurs when the variable is set to an unrecognized string.","triggerScenarios":"Setting an env var read by env_bool to a value outside {1,true,yes,on,0,false,no,off} after lowercasing and stripping whitespace, e.g. TRUE-ish words like 'enable', 'y', '2', or trailing punctuation.","commonSituations":"Copy-pasting 'TRUE' with a trailing quote or space from docs; using 'yes' vs 'ja' style values; scripts exporting \"$(flag)\" where the variable is empty-with-quotes or holds 'on/off' variants the parser doesn't know; mixing conventions with other tools that accept arbitrary truthy strings.","solutions":["Set the variable to one of 1, true, yes, on, 0, false, no, off (case-insensitive)","Unset or leave empty to use the default","Check for stray whitespace, quotes, or CR characters in your shell profile / CI config"],"exampleFix":"// before\nexport BENCH_VERBOSE=enabled\n// after\nexport BENCH_VERBOSE=true","handlingStrategy":"validation","validationCode":"import os\nALLOWED_TRUE = {\"1\", \"true\", \"yes\", \"on\"}\nALLOWED_FALSE = {\"0\", \"false\", \"no\", \"off\"}\ndef validate_bool_env(name: str) -> None:\n    raw = os.getenv(name)\n    if raw and raw.strip().lower() not in ALLOWED_TRUE | ALLOWED_FALSE:\n        raise SystemExit(f\"{name} must be one of 1/true/yes/on/0/false/no/off\")\nvalidate_bool_env(\"BENCH_VERBOSE\")","typeGuard":"def is_bool_literal(raw: str | None) -> bool:\n    return raw is not None and raw.strip().lower() in {\"1\",\"true\",\"yes\",\"on\",\"0\",\"false\",\"no\",\"off\"}","tryCatchPattern":"try:\n    run_bench()\nexcept ValueError as e:\n    if \"must be a boolean\" in str(e):\n        print(f\"Fix boolean env var: {e}\"); sys.exit(2)\n    raise","preventionTips":["Use only 1/0 or true/false for boolean env vars across all scripts","Watch for stray quotes/whitespace when exporting from shells or CI YAML","Keep one shared env_bool helper instead of ad-hoc parsing","Test config parsing in a preflight step"],"tags":["python","environment-variables","boolean-parsing","configuration"],"backgroundTag":"invalid-env-var-value","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}