{"record":{"id":"d77fa2873c850911","repo":"heygen-com/hyperframes","slug":"probe-index-i-out-of-range-0-255","errorCode":null,"errorMessage":"probe index ${i} out of range [0, 255]","messagePattern":"probe index (.+?) out of range \\[0, 255\\]","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/engine/scripts/generate-lut-reference.py","lineNumber":130,"sourceCode":"    return out\n\n\n# Mirror SRGB_TO_HDR_REFERENCE indices in alphaBlit.test.ts. Endpoints\n# (0, 1, 254, 255) catch off-by-one regressions; mid-range values (32, 64,\n# 96, 128, 160, 192, 224) sample the middle of both transfer curves.\nDEFAULT_PROBES: tuple[int, ...] = (0, 1, 10, 32, 64, 96, 128, 160, 192, 224, 254, 255)\n\n\ndef emit_json(hlg: list[int], pq: list[int]) -> None:\n    print(json.dumps({\"size\": 256, \"hlg\": hlg, \"pq\": pq}, indent=2))\n\n\ndef emit_probes(hlg: list[int], pq: list[int], probes: Iterable[int]) -> None:\n    # Output is paste-ready TS for SRGB_TO_HDR_REFERENCE in alphaBlit.test.ts.\n    print(\"const SRGB_TO_HDR_REFERENCE: readonly SrgbHdrProbe[] = [\")\n    for i in probes:\n        if not 0 <= i <= 255:\n            raise ValueError(f\"probe index {i} out of range [0, 255]\")\n        print(f\"  {{ srgb: {i}, hlg: {hlg[i]}, pq: {pq[i]} }},\")\n    print(\"];\")\n\n\ndef parse_indices(s: str) -> list[int]:\n    return [int(x.strip()) for x in s.split(\",\") if x.strip()]\n\n\ndef main() -> int:\n    parser = argparse.ArgumentParser(\n        description=\"Regenerate sRGB → BT.2020 (HLG/PQ) LUT reference values.\",\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n    )\n    parser.add_argument(\n        \"--probes\",\n        action=\"store_true\",\n        help=\"Emit a TS snippet ready to paste over SRGB_TO_HDR_REFERENCE.\",\n    )","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/engine/scripts/generate-lut-reference.py#L112-L148","documentation":"Thrown by emit_probes() in the LUT reference generator script when a probe index is outside the inclusive range [0, 255]. The script generates sRGB-to-BT.2020 (HLG/PQ) lookup table reference values and can emit a subset of probe entries for test fixtures. Each probe index must correspond to a valid 8-bit sRGB input value.","triggerScenarios":"The script is invoked with --probes '0,1,10,32,...' (or DEFAULT_PROBES) and one of the comma-separated values is negative, > 255, or non-integer. parse_indices() converts strings to int, then emit_probes() validates each with 0 <= i <= 255.","commonSituations":"A developer hand-edits the --probes argument and mistypes a value (e.g., 256 instead of 255). A script generates probe indices programmatically and produces an out-of-range value. The default probe list was modified to include edge cases beyond 8-bit range.","solutions":["Check the --probes argument for values outside 0-255 and correct them.","If generating probes programmatically, clamp: index = max(0, min(255, index)).","Use the default probe set (omit --probes) which is pre-validated: (0, 1, 10, 32, 64, 96, 128, 160, 192, 224, 254, 255).","Run with --help to see accepted ranges and examples."],"exampleFix":"# before\npython generate-lut-reference.py --probes 0,128,256\n\n# after\npython generate-lut-reference.py --probes 0,128,255","handlingStrategy":"validation","validationCode":"def validate_probes(probes):\n    for i in probes:\n        if not 0 <= i <= 255:\n            raise ValueError(f'probe index {i} out of range [0, 255]')\n    return probes","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the DEFAULT_PROBES tuple (already validated) when possible.","Clamp programmatically-generated indices: index = max(0, min(255, index)).","Validate before passing to emit_probes(), not after."],"tags":["lut","script","validation","color","range","python"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}