{"record":{"id":"43b6a60beb32ff17","repo":"kovidgoyal/kitty","slug":"key-is-not-a-valid-color-name","errorCode":null,"errorMessage":"{key} is not a valid color name","messagePattern":"(.+?) is not a valid color name","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"kitty/rc/set_tab_color.py","lineNumber":24,"sourceCode":"\nfrom kitty.rgb import to_color\n\nfrom .base import MATCH_TAB_OPTION, ArgsType, Boss, ParsingOfArgsFailed, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window\n\nif TYPE_CHECKING:\n    from kitty.cli_stub import SetTabColorRCOptions as CLIOptions\n\n\nvalid_color_names = frozenset('active_fg active_bg inactive_fg inactive_bg'.split())\n\n\ndef parse_colors(args: ArgsType) -> dict[str, int | None]:\n    ans: dict[str, int | None] = {}\n    for spec in args:\n        key, val = spec.split('=', 1)\n        key = key.lower()\n        if key.lower() not in valid_color_names:\n            raise KeyError(f'{key} is not a valid color name')\n        if val.lower() == 'none':\n            col: int | None = None\n        else:\n            q = to_color(val, validate=True)\n            if q is not None:\n                col = int(q)\n        ans[key.lower()] = col\n    return ans\n\n\nclass SetTabColor(RemoteCommand):\n    protocol_spec = __doc__ = \"\"\"\n    colors+/dict.colors: An object mapping names to colors as 24-bit RGB integers. A color value of null indicates it should be unset.\n    match/str: Which tab to change the color of\n    self/bool: Boolean indicating whether to use the tab of the window the command is run in\n    \"\"\"\n\n    short_desc = 'Change the color of the specified tabs in the tab bar'","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/rc/set_tab_color.py#L6-L42","documentation":"set-tab-color parses key=value specs where key must be one of the valid color names ('active', 'inactive', 'default', etc.). Unknown keys raise KeyError.","triggerScenarios":"kitten @set-tab-color foo=red, or a misspelled key such as 'activ=red'.","commonSituations":"Scripts guessing at color slot names; kitty versions differ in supported slots.","solutions":["Use valid keys only (e.g. color=..., or active/inactive as documented in @set-tab-color --help)","Check valid_color_names in kitty/rc/set_tab_color.py for your version"],"exampleFix":"# before\nkitten @set-tab-color active-background=red\n# after\nkitten @set-tab-color color=red","handlingStrategy":"type-guard","validationCode":"from kitty.rc.set_tab_color import valid_color_names\nassert key.lower() in valid_color_names","typeGuard":"def is_valid_color_name(k: str, valid) -> bool: return k.lower() in valid","tryCatchPattern":"except KeyError as e: print('unknown color slot:', e)","preventionTips":["Import valid_color_names for your kitty version when building specs dynamically"],"tags":["kitty","tab","validation"],"backgroundTag":"unknown-config-key","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}