{"record":{"id":"1efcfa736e4a9e7d","repo":"t8y2/dbx","slug":"name-must-be-positive","errorCode":null,"errorMessage":"{name} must be positive","messagePattern":"(.+?) must be positive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agents/drivers/argo-go/bench/agent_compare.py","lineNumber":632,"sourceCode":"\ndef required_path(name: str) -> Path:\n    value = os.getenv(name, \"\")\n    if not value:\n        raise ValueError(f\"{name} is required\")\n    path = Path(value).expanduser().resolve()\n    if not path.is_file():\n        raise FileNotFoundError(path)\n    return path\n\n\ndef env_default(name: str, fallback: str) -> str:\n    return os.getenv(name, \"\") or fallback\n\n\ndef env_int(name: str, fallback: int) -> int:\n    value = int(env_default(name, str(fallback)))\n    if value < 1:\n        raise ValueError(f\"{name} must be positive\")\n    return value\n\n\ndef env_int_list(name: str, fallback: list[int]) -> list[int]:\n    raw = os.getenv(name, \"\")\n    values = fallback if not raw else [int(value.strip()) for value in raw.split(\",\")]\n    if not values or any(value < 1 for value in values):\n        raise ValueError(f\"{name} must contain positive integers\")\n    return values\n\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","sourceCodeStart":614,"sourceCodeEnd":650,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/argo-go/bench/agent_compare.py#L614-L650","documentation":"env_int parses an environment variable as an integer (with fallback default) and enforces a lower bound: values below 1 raise ValueError \"{name} must be positive\". It protects knobs like page sizes, concurrency, and iteration counts from nonsensical zero/negative values.","triggerScenarios":"Exporting any env var read via env_int (called from main, connection_params, configured_workloads, query_workload, benchmark_concurrency, probe_candidate — e.g. BENCH_PAGE_SIZE, BENCH_CONCURRENCY) with 0, a negative number, or a non-numeric string that int() coerces oddly (int() on non-numeric actually raises its own ValueError, but 0/-1 hits this check).","commonSituations":"`export BENCH_CONCURRENCY=0` intending \"unlimited\"; negative value copied from docs of another tool; empty-string intent that env_default replaced with a wrong default; shell var set as `0` for a boolean-style flag.","solutions":["Set the variable to an integer >= 1 (e.g. `export BENCH_CONCURRENCY=4`)","Unset the variable to fall back to the built-in default","Check the variable name in the error message and make sure you're tuning the intended knob","Clamp or document values in the wrapper script: `export BENCH_PAGE_SIZE=$(( PAGE < 1 ? 1 : PAGE ))`"],"exampleFix":"// before\nexport BENCH_PAGE_SIZE=0\n// after\nexport BENCH_PAGE_SIZE=100","handlingStrategy":"validation","validationCode":"import os\nv = os.getenv(\"BENCH_CONCURRENCY\", \"\")\nif v and (not v.lstrip('-').isdigit() or int(v) < 1):\n    raise SystemExit(f\"BENCH_CONCURRENCY={v!r} must be a positive integer\")","typeGuard":null,"tryCatchPattern":"try:\n    n = env_int(\"BENCH_CONCURRENCY\", 4)\nexcept ValueError as e:\n    sys.exit(f\"bad env value: {e}\")","preventionTips":["Never use 0 or negatives for count-like knobs; unset the var to use defaults","Export integers without quotes/units (no \"10s\", \"0x10\")","Document each env knob's valid range in the bench README","Clamp user input in wrapper scripts before export"],"tags":["environment-variable","validation","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-14T00:17:10.932Z"}