{"record":{"id":"19ecb93fbf519fd8","repo":"kovidgoyal/kitty","slug":"invalid-color-name-raw-r","errorCode":null,"errorMessage":"Invalid color name: {raw!r}","messagePattern":"Invalid color name: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"kitty/rgb.py","lineNumber":37,"sourceCode":"def color_from_int(x: int) -> Color:\n    return Color((x >> 16) & 255, (x >> 8) & 255, x & 255)\n\n\ndef color_as_int(x: Color) -> int:\n    return int(x)\n\n\ndef color_as_sharp(x: Color) -> str:\n    return x.as_sharp\n\n\ndef color_as_sgr(x: Color) -> str:\n    return x.as_sgr\n\n\ndef to_color(raw: str, validate: bool = False) -> Color | None:\n    if (val := Color.parse_color(raw)) is None and validate:\n        raise ValueError(f'Invalid color name: {raw!r}')\n    return val\n","sourceCodeStart":19,"sourceCodeEnd":39,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/rgb.py#L19-L39","documentation":"to_color(raw, validate=True) raises ValueError when Color.parse_color cannot interpret the string as a color (#rrggbb, #rgb, color names, rgb:c/c/c forms).","triggerScenarios":"Passing strings like 'redd', '#12', 'rgb:1/2' or arbitrary text where a color spec is expected (themes, set-tab-color values, color_control calls).","commonSituations":"Typos in theme files, dynamically-built color strings without validation, catppuccin/other theme syntax kitty doesn't parse.","solutions":["Use a valid format: named color, #rgb/#rrggbb/#rrggbbaa, or rgb:r/g/b","Validate strings with Color.parse_color before passing when validate=False path is used elsewhere","Fix the typo in the theme/config value"],"exampleFix":"# before\nto_color('bluu', validate=True)\n# after\nto_color('#0000ff', validate=True)","handlingStrategy":"validation","validationCode":"from kitty.rgb import Color\nassert Color.parse_color(raw) is not None, f'bad color: {raw!r}'","typeGuard":"def is_valid_color(s: str) -> bool: return Color.parse_color(s) is not None","tryCatchPattern":"except ValueError: fall back to a default color and warn","preventionTips":["Validate theme values in CI for kitty configs","Prefer hex formats when generating colors programmatically"],"tags":["kitty","color","validation"],"backgroundTag":"invalid-color-value","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}