{"record":{"id":"bf5ab6f16de6b976","repo":"kovidgoyal/kitty","slug":"failed-to-parse-map-v-with-error-w","errorCode":null,"errorMessage":"Failed to parse map = %#v with error: %w","messagePattern":"Failed to parse map = %#v with error: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kitty/conf/generate.py","lineNumber":714,"sourceCode":"        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:\n    # To use run it as:\n    # kitty +runpy 'from kitty.conf.generate import main; main()' /path/to/kitten/file.py\n    import importlib\n    import sys\n\n    from kittens.runner import path_to_custom_kitten, resolved_kitten\n    from kitty.constants import config_dir\n","sourceCodeStart":696,"sourceCodeEnd":732,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/conf/generate.py#L696-L732","documentation":"Specialized form of 545 for the 'map' key: kitty keyboard shortcuts in config files are parsed by config.ParseMap in Go. When the map value's syntax is invalid (malformed key mapping, missing action, bad chord syntax), this wrapper reports the raw map string plus the underlying ParseMap error.","triggerScenarios":"Writing a 'map' line with invalid syntax in kitty.conf, e.g. 'map ctrl+ send_text hello', 'map = ', or chord/action combos ParseMap rejects, when the config is consumed by a Go-based kitten parser.","commonSituations":"Complex map lines with missing actions, unmatched syntax, or new map grammar from a newer kitty not yet in the generated Go parser; copy-pasted maps with smart quotes or invisible characters; maps using deprecated action names.","solutions":["Read the inner error from ParseMap — it pinpoints the malformed segment of the mapping","Validate the line against kitty's map syntax docs (map key_spec action args)","Test interactively: kitty --debug-config or kitty --debug-keyboard to see if the map parses in the main config layer","Simplify: temporarily comment out maps and re-add one by one to find the offender"],"exampleFix":"# before\nmap ctrl+ page_up scroll\n\n# after\nmap ctrl+page_up scroll_page_up","handlingStrategy":"validation","validationCode":"if strings.HasPrefix(line, \"map \") {\n    parts := strings.Fields(line)\n    if len(parts) < 3 {\n        return fmt.Errorf(\"map line needs a key spec and an action: %q\", line)\n    }\n}","typeGuard":"func isValidMapLine(line string) bool {\n    p := strings.Fields(line)\n    return len(p) >= 3 && p[0] == \"map\"\n}","tryCatchPattern":"if err := cfg.Parse(\"map\", mapVal); err != nil {\n    if strings.Contains(err.Error(), \"Failed to parse map\") {\n        log.Printf(\"skipping bad keybinding: %s\", mapVal)\n        continue\n    }\n    return err\n}","preventionTips":["Test map lines with kitty --debug-keyboarding/--debug-config","Add map changes one at a time to isolate bad lines","Keep map grammar current with your kitty version's docs"],"tags":["kitty","config","keybinding","map","parse-error"],"backgroundTag":"keybinding-map-parse-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}