{"record":{"id":"b64442c4b18778ec","repo":"micro-editor/micro","slug":"invalid-event-s","errorCode":null,"errorMessage":"Invalid event %s","messagePattern":"Invalid event (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/action/bindings.go","lineNumber":128,"sourceCode":"\t// \tInfoMapKey(e, v)\n\t// }\n}\n\nvar r = regexp.MustCompile(\"<(.+?)>\")\n\nfunc findEvents(k string) (b KeySequenceEvent, ok bool, err error) {\n\tvar events []Event = nil\n\tfor len(k) > 0 {\n\t\tgroups := r.FindStringSubmatchIndex(k)\n\n\t\tif len(groups) > 3 {\n\t\t\tif events == nil {\n\t\t\t\tevents = make([]Event, 0, 3)\n\t\t\t}\n\n\t\t\te, ok := findSingleEvent(k[groups[2]:groups[3]])\n\t\t\tif !ok {\n\t\t\t\treturn KeySequenceEvent{}, false, errors.New(\"Invalid event \" + k[groups[2]:groups[3]])\n\t\t\t}\n\n\t\t\tevents = append(events, e)\n\n\t\t\tk = k[groups[3]+1:]\n\t\t} else {\n\t\t\treturn KeySequenceEvent{}, false, nil\n\t\t}\n\t}\n\n\treturn KeySequenceEvent{events}, true, nil\n}\n\n// findSingleEvent will find binding Key 'b' using string 'k'\nfunc findSingleEvent(k string) (b Event, ok bool) {\n\tmodifiers := tcell.ModNone\n\n\t// First, we'll strip off all the modifiers in the name and add them to the","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/micro-editor/micro/blob/1c8b82b32e408a5faf340039ed92d5266bea3293/internal/action/bindings.go#L110-L146","documentation":"Thrown by findEvents() in internal/action/bindings.go while parsing a key *sequence* like \"<Ctrl-x>k\". The regex `<(.+?)>` splits the string into <token> groups and each token must resolve via findSingleEvent (a known key name in keyEvents/mouseEvents, modifiers + single rune, or an escape sequence). If any single token inside the angle brackets is unrecognized, parsing aborts with 'Invalid event <token>'. This surfaces through findEvent, i.e. every TryBindKey/UnbindKey/BindKey call including InitBindings at startup and the interactive >bind command.","triggerScenarios":"bindings.json (or a >bind argument) contains a sequence with a bad inner token, e.g. \"<Ctrl-q><quux>\": 'Ctrl-q' parses but 'quux' is not in keyEvents/mouseEvents and is longer than one character, so findSingleEvent returns !ok and findEvents errors. Also triggered by typos like \"<Cntrl-s>\" or \"<Page Down>\" inside brackets.","commonSituations":"Hand-editing bindings.json using Vim/Emacs-style notation that micro does not support; copying snippets from outdated blog posts or other editors' configs; renaming a binding in a Lua plugin that calls bindings.TryBindKeyplug.","solutions":["Fix the token inside <...> to a name micro knows: Ctrl<Letter>, Alt<Rune|Name>, Shift<Name>, F1-F12, PageUp/Down, Home, End, ArrowUp/Down/Left/Right, Delete, Insert, MouseLeft/Middle/Right (optionally with Drag/Release suffix)","Open > help keybindings and copy the exact event-name grammar from the shipped documentation","For single characters use the bare rune ('x') and for raw escapes use \"\\u001b...\" RawEvent form instead of inventing names","Re-run micro and watch the infobar; the message names exactly which token failed"],"exampleFix":"// before: ~/.config/micro/bindings.json\n\"<Cntrl-s>\": \"Save\",\n\"<Ctrl-x>quux\": \"Quit\"\n\n// after\n\"CtrlS\": \"Save\",\n\"<Ctrl-x>k\": \"Quit\"","handlingStrategy":"validation","validationCode":"// Validate a binding string before TryBindKey/BindKey\ntokenRe := regexp.MustCompile(`<(.+?)>`)\nfunc validBinding(k string) bool {\n    for _, m := range tokenRe.FindAllStringSubmatch(k, -1) {\n        if !validSingleEvent(m[1]) {\n            return false // each <token> must itself be a valid event name\n        }\n    }\n    return true\n}\n// validSingleEvent mirrors findSingleEvent: optional Ctrl/Alt/Shift prefixes +\n// known key name (F1..F12, PageUp, Enter, ArrowLeft...), known mouse name\n// (optionally +Drag/+Release), or exactly one rune.","typeGuard":null,"tryCatchPattern":"if _, err := action.TryBindKey(seq, act, true, true); err != nil {\n    if strings.HasPrefix(err.Error(), \"Invalid event \") {\n        // extract the token, suggest closest known event name, keep going\n        log.Printf(\"skipping bad binding %q: %v\", seq, err)\n        continue\n    }\n    return err\n}","preventionTips":["Source event names only from > help keybindings, never from other editors' docs","Lint bindings.json in CI with a regex pass over <...> tokens","Prefer simple single-key names (CtrlS, AltLeft) over exotic sequences when scripting binds"],"tags":["keybinding","config","parsing","json"],"backgroundTag":null,"analyzedSha":"1c8b82b32e408a5faf340039ed92d5266bea3293","analyzedAt":"2026-08-15T20:01:45.134Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}