{"record":{"id":"62836ba05436b1bb","repo":"nexu-io/open-design","slug":"invalid-chroma-key-color-value-expected-rrggb-62836b","errorCode":null,"errorMessage":"invalid chroma key color: {value}; expected #RRGGBB","messagePattern":"invalid chroma key color: (.+?); expected #RRGGBB","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/hatch-pet/scripts/prepare_pet_run.py","lineNumber":306,"sourceCode":"        \"cell_width\": ATLAS[\"cell_width\"],\n        \"cell_height\": ATLAS[\"cell_height\"],\n        \"safe_margin_x\": LAYOUT_GUIDE_SAFE_MARGIN_X,\n        \"safe_margin_y\": LAYOUT_GUIDE_SAFE_MARGIN_Y,\n        \"usage\": \"layout guide input only; do not copy visible guide lines into generated sprite strips\",\n    }\n\n\ndef create_layout_guides(run_dir: Path) -> list[dict[str, object]]:\n    guide_dir = run_dir / LAYOUT_GUIDE_DIR\n    return [\n        create_layout_guide(guide_dir / f\"{state}.png\", state, frames)\n        for state, _row, frames, _purpose in ROWS\n    ]\n\n\ndef parse_hex_color(value: str) -> tuple[int, int, int]:\n    if not re.fullmatch(r\"#[0-9a-fA-F]{6}\", value):\n        raise SystemExit(f\"invalid chroma key color: {value}; expected #RRGGBB\")\n    return tuple(int(value[index : index + 2], 16) for index in (1, 3, 5))\n\n\ndef rgb_to_hex(rgb: tuple[int, int, int]) -> str:\n    return f\"#{rgb[0]:02X}{rgb[1]:02X}{rgb[2]:02X}\"\n\n\ndef color_distance(left: tuple[int, int, int], right: tuple[int, int, int]) -> float:\n    return math.sqrt(sum((left[index] - right[index]) ** 2 for index in range(3)))\n\n\ndef sampled_reference_pixels(paths: list[Path]) -> list[tuple[int, int, int]]:\n    pixels: list[tuple[int, int, int]] = []\n    for path in paths:\n        with Image.open(path) as opened:\n            image = opened.convert(\"RGBA\")\n            image.thumbnail((128, 128), Image.Resampling.LANCZOS)\n            data = image.tobytes()","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/hatch-pet/scripts/prepare_pet_run.py#L288-L324","documentation":"Raised by parse_hex_color in prepare_pet_run.py when the --chroma-key value does not match the regex #[0-9a-fA-F]{6} (and is not the default \"auto\", which is handled earlier in choose_chroma_key). The chroma key must be a 6-digit hex color like #FF00FF because it is sliced into R/G/B byte pairs.","triggerScenarios":"Passing --chroma-key without a leading # (e.g. FF00FF), with 3-digit shorthand (#F0F), with extra characters (#FF00FF00), or with values outside 0-9a-f.","commonSituations":"Copying a hex from a color picker that omits #; using CSS 3-digit shorthand; passing an 8-digit RGBA hex; typos like #GGGGGG.","solutions":["Pass a 6-digit uppercase or lowercase hex with a leading # (e.g. --chroma-key #FF00FF).","Or omit the flag to use --chroma-key auto, which picks a safe key from the reference image.","Validate against the same regex before running if generating the value programmatically.","Re-run prepare_pet_run.py."],"exampleFix":"// before\npython prepare_pet_run.py --chroma-key FF00FF --reference cat.png\n# SystemExit: invalid chroma key color: FF00FF; expected #RRGGBB\n\n// after\npython prepare_pet_run.py --chroma-key \"#FF00FF\" --reference cat.png","handlingStrategy":"validation","validationCode":"import re\n\ndef parse_hex_color(value: str):\n    if not re.fullmatch(r\"#[0-9a-fA-F]{6}\", value):\n        raise SystemExit(f\"invalid chroma key color: {value}; expected #RRGGBB\")","typeGuard":"import re\n\ndef is_hex_color(value: str) -> bool:\n    return bool(re.fullmatch(r\"#[0-9a-fA-F]{6}\", value))","tryCatchPattern":null,"preventionTips":["Always include the leading # in --chroma-key values.","Use 6-digit hex; do not pass 3-digit shorthand or 8-digit RGBA.","Omit the flag (or pass auto) to let prepare_pet_run.py choose a safe key."],"tags":["cli","chroma-key","validation","regex","system-exit"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}