{"record":{"id":"9712b599678c5a37","repo":"kovidgoyal/kitty","slug":"failed-to-parse-s-v-with-error-w","errorCode":null,"errorMessage":"Failed to parse %s = %#v with error: %w","messagePattern":"Failed to parse (.+?) = %#v with error: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kitty/conf/generate.py","lineNumber":706,"sourceCode":"        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:\n                a(f'c.{oname} = append(c.{oname}, temp_val...)')\n            else:\n                a(f'c.{oname} = temp_val')\n        if keyboard_shortcuts:\n            a('case \"map\":')\n            a('tempsc, err := config.ParseMap(val)')\n            a('if err != nil { return fmt.Errorf(\"Failed to parse map = %#v with error: %w\", val, err) }')\n            a('c.KeyboardShortcuts = append(c.KeyboardShortcuts, tempsc)')\n        a('}')\n        a('return}')\n    else:\n        a('return fmt.Errorf(\"Unknown configuration key: %#v\", key)')\n        a('}')\n    return '\\n'.join(lines)\n\n\ndef main() -> None:","sourceCodeStart":688,"sourceCodeEnd":724,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/conf/generate.py#L688-L724","documentation":"Generated Go code for each known config option: the option key was recognized, but its value failed the option's type-specific parser (e.g. an integer parser receiving text, a color parser receiving an invalid color, a bool parser receiving 'yesn'). The wrapping error adds context (option name and raw value) to the underlying parse failure.","triggerScenarios":"A recognized kitty option whose value doesn't parse: scrollback_lines = lots, foreground = notacolor, remember_window_size = 42 — hit via kitty.conf, -o flags, or remote control when processed by a Go-embedded config parser.","commonSituations":"Unit mismatches or typos in values; copy-pasting configs across kitty versions where value syntax changed; locale differences (comma vs dot in numbers); feeding Python-syntax values to Go parsers.","solutions":["Check the inner error (%w) — it states what the value couldn't be parsed as; fix the value's format/type","Look up the option in kitty docs for its expected value syntax","Quote strings containing special characters; use documented units/booleans (yes/no/true/false)","Upgrade kitty if the value format is valid in a newer generated parser"],"exampleFix":"# before\nscrollback_lines = unlimited-ish\nforeground = bluish\n\n# after\nscrollback_lines = 10000\nforeground = #c0c0ff","handlingStrategy":"try-catch","validationCode":"// validate common types before parse\nif key == \"scrollback_lines\" {\n    if _, err := strconv.Atoi(val); err != nil {\n        return fmt.Errorf(\"%s must be an integer\", key)\n    }\n}","typeGuard":"func isInt(s string) bool { _, err := strconv.Atoi(s); return err == nil }","tryCatchPattern":"if err := cfg.Parse(key, val); err != nil {\n    if strings.Contains(err.Error(), \"Failed to parse\") {\n        log.Printf(\"bad value for %s, using default\", key)\n        continue\n    }\n    return err\n}","preventionTips":["Match value syntax to docs (ints, colors as #rrggbb, bools as yes/no)","Validate config values in CI with kitty --debug-config","Avoid copy-pasting configs across major versions"],"tags":["kitty","config","parse-error","value-format","generated-code"],"backgroundTag":"config-value-parse-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}