kovidgoyal/kitty · error · KeyError
{key} is not a valid color name
Error message
{key} is not a valid color name What it means
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.
Source
Thrown at kitty/rc/set_tab_color.py:24
from kitty.rgb import to_color
from .base import MATCH_TAB_OPTION, ArgsType, Boss, ParsingOfArgsFailed, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
if TYPE_CHECKING:
from kitty.cli_stub import SetTabColorRCOptions as CLIOptions
valid_color_names = frozenset('active_fg active_bg inactive_fg inactive_bg'.split())
def parse_colors(args: ArgsType) -> dict[str, int | None]:
ans: dict[str, int | None] = {}
for spec in args:
key, val = spec.split('=', 1)
key = key.lower()
if key.lower() not in valid_color_names:
raise KeyError(f'{key} is not a valid color name')
if val.lower() == 'none':
col: int | None = None
else:
q = to_color(val, validate=True)
if q is not None:
col = int(q)
ans[key.lower()] = col
return ans
class SetTabColor(RemoteCommand):
protocol_spec = __doc__ = """
colors+/dict.colors: An object mapping names to colors as 24-bit RGB integers. A color value of null indicates it should be unset.
match/str: Which tab to change the color of
self/bool: Boolean indicating whether to use the tab of the window the command is run in
"""
short_desc = 'Change the color of the specified tabs in the tab bar'View on GitHub (pinned to 6d5d0c4406)
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
Example fix
# before kitten @set-tab-color active-background=red # after kitten @set-tab-color color=red
Defensive patterns
Strategy: type-guard
Validate before calling
from kitty.rc.set_tab_color import valid_color_names assert key.lower() in valid_color_names
Type guard
def is_valid_color_name(k: str, valid) -> bool: return k.lower() in valid
Try / catch
except KeyError as e: print('unknown color slot:', e) Prevention
- Import valid_color_names for your kitty version when building specs dynamically
When it happens
Trigger: kitten @set-tab-color foo=red, or a misspelled key such as 'activ=red'.
Common situations: Scripts guessing at color slot names; kitty versions differ in supported slots.
Related errors
- Unknown type_of_input: {type_of_input}
- Unknown keys in multicell_command:
- The value {x} is not a known choice
- The value {val} is not a valid choice for progress_bar
- The value {val} is not a valid choice for scrollbar
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/43b6a60beb32ff17.
Report an issue: GitHub.