{"record":{"id":"15bc86ffde042ce5","repo":"kovidgoyal/kitty","slug":"x-is-not-a-valid-value-for-alias-valid-values","errorCode":null,"errorMessage":"{x} is not a valid value for {alias}. Valid values are y, yes, true, n, no, false only","messagePattern":"(.+?) is not a valid value for (.+?)\\. Valid values are y, yes, true, n, no, false only","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"kitty/cli.py","lineNumber":583,"sourceCode":"                t = 'str'\n        elif otype.startswith('bool-'):\n            t = 'bool'\n        else:\n            raise ValueError(f'Unknown CLI option type: {otype}')\n        ans.append(f'    {name}: {t}')\n    for x in extra_fields:\n        ans.append(f'    {x}')\n    return '\\n'.join(ans) + '\\n\\n\\n'\n\n\nbool_map = {'y': True, 'yes': True, 'true': True, 'n': False, 'no': False, 'false': False}\n\n\ndef to_bool(alias: str, x: str) -> bool:\n    try:\n        return bool_map[x]\n    except KeyError:\n        raise SystemExit(f'{x} is not a valid value for {alias}. Valid values are y, yes, true, n, no, false only')\n\n\nclass Options:\n    do_print = True\n\n    def __init__(self, seq: OptionSpecSeq, usage: str | None, message: str | None, appname: str | None):\n        self.seq = seq\n        self.usage, self.message, self.appname = usage, message, appname\n        self.names_map, self.alias_map, self.values_map = get_option_maps(seq)\n        self.help_called = self.version_called = False\n\n    def handle_help(self) -> NoReturn:\n        if self.do_print:\n            print_help_for_seq(self.seq, self.usage, self.message, self.appname or appname)\n        self.help_called = True\n        raise SystemExit(0)\n\n    def handle_version(self) -> NoReturn:","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/cli.py#L565-L601","documentation":"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.","triggerScenarios":"Passing e.g. --some-flag=maybe or =1 / =on to a boolean kitty CLI option parsed by to_bool.","commonSituations":"Users assuming 0/1 or on/off work; shell scripts setting boolean options from unchecked variables.","solutions":["Use one of: y, yes, true, n, no, false","Quote the value correctly so shell expansion doesn't mangle it","If passing a variable, normalize it to the accepted set first"],"exampleFix":"# before\nkitty --scrollbar=1\n# after\nkitty --scrollbar=yes","handlingStrategy":"validation","validationCode":"BOOL_VALUES = {'y','yes','true','n','no','false'}\nif value.lower() not in BOOL_VALUES:\n    value = 'yes'  # or reject\nkitty_cmd = ['kitty', f'--opt={value}']","typeGuard":"def is_valid_kitty_bool(x: str) -> bool:\n    return x.lower() in {'y','yes','true','n','no','false'}","tryCatchPattern":null,"preventionTips":["Normalize booleans to y/n before passing to kitty CLI","Avoid 0/1/on/off spellings"],"tags":["kitty","cli","boolean","option-parsing"],"backgroundTag":"invalid-cli-argument","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}