{"record":{"id":"f24f69dd56821a86","repo":"kovidgoyal/kitty","slug":"v-is-not-a-valid-value-for-s-valid-values-are","errorCode":null,"errorMessage":"%#v is not a valid value for %s. Valid values are: %s","messagePattern":"%#v is not a valid value for (.+?)\\. Valid values are: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kitty/conf/generate.py","lineNumber":689,"sourceCode":"        for i, c in enumerate(choice_vals):\n            c = cval(c)\n            if i == 0:\n                a(f'{oname}_{c} {oname}_Choice_Type = iota')\n            else:\n                a(f'{oname}_{c}')\n        a(')')\n        a(f'func (x {oname}_Choice_Type) String() string {{')\n        a('switch x {')\n        a('default: return \"\"')\n        for c in choice_vals:\n            a(f'case {oname}_{cval(c)}: return \"{c}\"')\n        a('}}')\n        a(f'func {go_parsers[oname].split(\"(\")[0]}(val string) (ans {go_types[oname]}, err error) {{')\n        a('switch val {')\n        for c in choice_vals:\n            a(f'case \"{c}\": return {oname}_{cval(c)}, nil')\n        vals = ', '.join(choice_vals)\n        a(f'default: return ans, fmt.Errorf(\"%#v is not a valid value for %s. Valid values are: %s\", val, \"{c}\", \"{vals}\")')\n        a('}}')\n\n    has_parsers = bool(go_parsers or keyboard_shortcuts)\n    a('func (c *Config) Parse(key, val string) (err error) {')\n    if has_parsers:\n        a('switch key {')\n        a('default: return fmt.Errorf(\"Unknown configuration key: %#v\", key)')\n        for oname, pname in go_parsers.items():\n            ol = oname.lower()\n            is_multiple = oname in multiopts\n            a(f'case \"{ol}\":')\n            if is_multiple:\n                a(f'var temp_val []{go_types[oname]}')\n            else:\n                a(f'var temp_val {go_types[oname]}')\n            a(f'temp_val, err = {pname}')\n            a(f'if err != nil {{ return fmt.Errorf(\"Failed to parse {ol} = %#v with error: %w\", val, err) }}')\n            if is_multiple:","sourceCodeStart":671,"sourceCodeEnd":707,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/conf/generate.py#L671-L707","documentation":"This error is generated (by kitty's config-code generator, generate.py) into the Go parser for every option with a fixed set of valid values (a choices option). At runtime, when a config file or remote-control command supplies a value not in the option's list of allowed choices, the generated switch's default branch returns this error naming the value, the option, and the valid values.","triggerScenarios":"Setting a choices-typed kitty option to an invalid string in kitty.conf (e.g. background_opacity = maybe), passing it via kitty -o key=value, or sending it over the remote control protocol to a Go-based parser (kitten like icat/transfer that embeds the config parser).","commonSituations":"Typos in kitty.conf values; using an option value from a newer/older kitty version than the parser was generated from; copy-pasted configs from tutorials with deprecated values (e.g. old font styles or deprecated strategies).","solutions":["Read the error message: it lists every valid value — correct the value in kitty.conf or the -o argument to one of them","Check kitty docs for the option to confirm supported values in your installed version","Upgrade kitty if the value is valid in a newer release (the generated parser lags behind)","Remove the line to fall back to the default if you don't need the setting"],"exampleFix":"# before\nbackground_opacity_layout = block\ncolor_strategy = maybe\n\n# after\nbackground_opacity_layout = block\n# use only values listed in the error, e.g.:\nsync_strategy = resize","handlingStrategy":"validation","validationCode":"valid := map[string]map[string]bool{ /* from generated schema */\n  \"background_opacity_strategy\": {\"block\": true, \"single\": true},\n}\nif opts, ok := valid[key]; ok && !opts[val] {\n    return fmt.Errorf(\"invalid value %q for %s; allowed: %v\", val, key, opts)\n}","typeGuard":"func isValidChoice(key, val string, schema map[string][]string) bool {\n    for _, c := range schema[key] {\n        if c == val {\n            return true\n        }\n    }\n    return false\n}","tryCatchPattern":"if err := cfg.Parse(key, val); err != nil {\n    if strings.Contains(err.Error(), \"is not a valid value for\") {\n        warnAndUseDefault(key, val)\n    } else {\n        return err\n    }\n}","preventionTips":["Lint kitty.conf with kitty --debug-config before deployment","Pin configs to documented value sets for your kitty version","Automate config checks in CI for generated parsers"],"tags":["kitty","config","validation","generated-code","choices"],"backgroundTag":"config-value-validation-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}