ssssssss-team/spider-flow · error · Error

Unrecognized modifier name: " + mod

Error message

Unrecognized modifier name: " + mod

What it means

CodeMirror normalizes key names like 'Cmd-X' or 'Shift-Alt-F' via lookupKey naming code; each dash-separated modifier token must match cmd/meta/m, a(lt), c/ctrl/control, or s(hift). Any other modifier token throws this error.

Solutions

  1. Use only recognized modifiers: Cmd (Meta), Alt, Ctrl, Shift — e.g. 'Alt-Shift-F'
  2. Replace '+' separators with '-' and 'Option' with 'Alt' (or 'Cmd' for Meta on macOS)
  3. Use the special 'Mod-' prefix which maps to Cmd on macOS and Ctrl elsewhere

Example fix

// before
extraKeys: {"Option+Shift-F": format}
// after
extraKeys: {"Alt-Shift-F": format}
Defensive patterns

Strategy: validation

Validate before calling

var OK = /^(cmd|meta|m|a(lt)?|c|ctrl|control|s(hift)?)$/i;
function keyIsValid(key) {
  var parts = key.split("-");
  return parts.slice(0, -1).every(function(p) { return OK.test(p); });
}
if (!keyIsValid(userKey)) console.error("bad modifier in", userKey);

Try / catch

try {
  extraKeys[normalizedKey] = handler;
} catch (e) {
  if (/Unrecognized modifier name/.test(e.message)) {
    console.warn("Falling back: unknown key combo", normalizedKey);
  } else { throw e; }
}

Prevention

When it happens

Trigger: Defining an extraKeys/keyMap entry with a misspelled or unsupported modifier, e.g. {'Option-S': fn}, {'Ctrl+Shift-N': fn} (plus signs not allowed), or localized/abbreviated modifiers like 'CmdOrCtrl' in normalizeKeyName paths.

Common situations: Porting keymaps from other editors (using 'Option', '+', 'Mod' in the wrong context), typos like 'Shfit-', or building key names dynamically from user input.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of ssssssss-team/spider-flow@c799cca99c (2026-09-08). Data as JSON: /api/errors/b44cf54acf987a22. Report an issue: GitHub.

Appendix: source

Thrown at spider-flow-web/src/main/resources/static/js/codemirror/codemirror.js:6728

    "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
    "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
    "fallthrough": ["basic", "emacsy"]
  };
  keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;

  // KEYMAP DISPATCH

  function normalizeKeyName(name) {
    var parts = name.split(/-(?!$)/);
    name = parts[parts.length - 1];
    var alt, ctrl, shift, cmd;
    for (var i = 0; i < parts.length - 1; i++) {
      var mod = parts[i];
      if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true; }
      else if (/^a(lt)?$/i.test(mod)) { alt = true; }
      else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; }
      else if (/^s(hift)?$/i.test(mod)) { shift = true; }
      else { throw new Error("Unrecognized modifier name: " + mod) }
    }
    if (alt) { name = "Alt-" + name; }
    if (ctrl) { name = "Ctrl-" + name; }
    if (cmd) { name = "Cmd-" + name; }
    if (shift) { name = "Shift-" + name; }
    return name
  }

  // This is a kludge to keep keymaps mostly working as raw objects
  // (backwards compatibility) while at the same time support features
  // like normalization and multi-stroke key bindings. It compiles a
  // new normalized keymap, and then updates the old object to reflect
  // this.
  function normalizeKeyMap(keymap) {
    var copy = {};
    for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) {
      var value = keymap[keyname];
      if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue }

View on GitHub (pinned to c799cca99c)