{"record":{"id":"dbc289507ce52738","repo":"abi/screenshot-to-code","slug":"iou-threshold-must-be-between-0-and-1","errorCode":null,"errorMessage":"--iou-threshold must be between 0 and 1","messagePattern":"--iou-threshold must be between 0 and 1","errorType":"validation","errorClass":"SystemExit","httpStatus":null,"severity":"warning","filePath":"backend/evals/asset_extraction_benchmark.py","lineNumber":850,"sourceCode":"    )\n    parser.add_argument(\"--output-dir\", type=Path)\n    parser.add_argument(\n        \"--iou-threshold\",\n        type=float,\n        default=DEFAULT_IOU_THRESHOLD,\n    )\n    return parser.parse_args()\n\n\nasync def main() -> None:\n    load_dotenv(Path(\".env\"))\n    args = parse_args()\n    if not args.live:\n        raise SystemExit(\n            \"Live API calls are disabled by default. Re-run with --live to opt in.\"\n        )\n    if not 0 <= args.iou_threshold <= 1:\n        raise SystemExit(\"--iou-threshold must be between 0 and 1\")\n    api_key = os.environ.get(\"GEMINI_API_KEY\")\n    if not api_key:\n        raise SystemExit(\"Missing GEMINI_API_KEY\")\n    output_dir = args.output_dir or (\n        DEFAULT_OUTPUT_ROOT / time.strftime(\"%Y%m%d_%H%M%S\")\n    )\n    await run_benchmark(\n        api_key=api_key,\n        output_dir=output_dir,\n        iou_threshold=args.iou_threshold,\n    )\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n","sourceCodeStart":832,"sourceCodeEnd":866,"githubUrl":"https://github.com/abi/screenshot-to-code/blob/d026163f586dfa8c5c10d28c36edd59a9d3b0e88/backend/evals/asset_extraction_benchmark.py#L832-L866","documentation":"SystemExit raised when the --iou-threshold CLI argument falls outside [0, 1]. IoU (intersection over union) is mathematically bounded to that interval, so any other value would make matching results meaningless; the check runs after the --live gate and before the key check.","triggerScenarios":"Passing e.g. --iou-threshold 1.2 or -0.5 (including values like 1.0000001 from float parsing) to the benchmark CLI.","commonSituations":"Thinking of IoU as a percentage (passing 50 instead of 0.5), or shell-quoting mistakes that pass an empty string which argparse rejects differently.","solutions":["Pass a fraction between 0 and 1, e.g. --iou-threshold 0.5.","If you meant percent, divide by 100 first."],"exampleFix":"# before\n--iou-threshold 70\n\n# after\n--iou-threshold 0.7","handlingStrategy":"validation","validationCode":"if not 0.0 <= float(iou) <= 1.0:\n    raise ValueError(\"iou-threshold must be a fraction in [0,1]\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember IoU thresholds are fractions, not percentages.","Clamp user-supplied thresholds to [0,1] in wrapper scripts."],"tags":["cli","validation","benchmark","iou"],"backgroundTag":null,"analyzedSha":"d026163f586dfa8c5c10d28c36edd59a9d3b0e88","analyzedAt":"2026-08-14T22:02:06.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}