kovidgoyal/kitty · error · SystemExit

{x} is not a valid value for {alias}. Valid values are y, ye

Error message

{x} is not a valid value for {alias}. Valid values are y, yes, true, n, no, false only

What it means

cli.to_bool parses boolean CLI options and raises SystemExit (printing the message and exiting) when the user supplied a value outside the accepted set y/yes/true/n/no/false for a boolean option.

Source

Thrown at kitty/cli.py:583

                t = 'str'
        elif otype.startswith('bool-'):
            t = 'bool'
        else:
            raise ValueError(f'Unknown CLI option type: {otype}')
        ans.append(f'    {name}: {t}')
    for x in extra_fields:
        ans.append(f'    {x}')
    return '\n'.join(ans) + '\n\n\n'


bool_map = {'y': True, 'yes': True, 'true': True, 'n': False, 'no': False, 'false': False}


def to_bool(alias: str, x: str) -> bool:
    try:
        return bool_map[x]
    except KeyError:
        raise SystemExit(f'{x} is not a valid value for {alias}. Valid values are y, yes, true, n, no, false only')


class Options:
    do_print = True

    def __init__(self, seq: OptionSpecSeq, usage: str | None, message: str | None, appname: str | None):
        self.seq = seq
        self.usage, self.message, self.appname = usage, message, appname
        self.names_map, self.alias_map, self.values_map = get_option_maps(seq)
        self.help_called = self.version_called = False

    def handle_help(self) -> NoReturn:
        if self.do_print:
            print_help_for_seq(self.seq, self.usage, self.message, self.appname or appname)
        self.help_called = True
        raise SystemExit(0)

    def handle_version(self) -> NoReturn:

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Use one of: y, yes, true, n, no, false
  2. Quote the value correctly so shell expansion doesn't mangle it
  3. If passing a variable, normalize it to the accepted set first

Example fix

# before
kitty --scrollbar=1
# after
kitty --scrollbar=yes
Defensive patterns

Strategy: validation

Validate before calling

BOOL_VALUES = {'y','yes','true','n','no','false'}
if value.lower() not in BOOL_VALUES:
    value = 'yes'  # or reject
kitty_cmd = ['kitty', f'--opt={value}']

Type guard

def is_valid_kitty_bool(x: str) -> bool:
    return x.lower() in {'y','yes','true','n','no','false'}

Prevention

When it happens

Trigger: Passing e.g. --some-flag=maybe or =1 / =on to a boolean kitty CLI option parsed by to_bool.

Common situations: Users assuming 0/1 or on/off work; shell scripts setting boolean options from unchecked variables.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/15bc86ffde042ce5. Report an issue: GitHub.