{"record":{"id":"e1a32eae646143c1","repo":"Mintplex-Labs/anything-llm","slug":"key-requires-key-argument-e-g-enter-tab-esca","errorCode":null,"errorMessage":"key requires <key> argument (e.g. Enter, Tab, Escape)","messagePattern":"key requires <key> argument \\(e\\.g\\. Enter, Tab, Escape\\)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"open-computer/services/interface-service/utils/cdp-input.js","lineNumber":175,"sourceCode":"          key: char,\n          code: charToCode(char),\n          unmodifiedText: char,\n        }, sessionId);\n\n        await cdpSend(ws, \"Input.dispatchKeyEvent\", {\n          type: \"keyUp\",\n          key: char,\n          code: charToCode(char),\n        }, sessionId);\n\n        await sleep(keystrokeDelay());\n      }\n\n      process.stdout.write(`typed ${text.length} chars`);\n\n    } else if (action === \"key\") {\n      const key = process.argv[3];\n      if (!key) throw new Error(\"key requires <key> argument (e.g. Enter, Tab, Escape)\");\n\n      const keyDef = specialKeys[key] || { key, code: `Key${key.toUpperCase()}` };\n\n      await cdpSend(ws, \"Input.dispatchKeyEvent\", {\n        type: \"keyDown\",\n        key: keyDef.key,\n        code: keyDef.code,\n        windowsVirtualKeyCode: keyDef.keyCode || 0,\n        nativeVirtualKeyCode: keyDef.keyCode || 0,\n      }, sessionId);\n      await sleep(50);\n\n      await cdpSend(ws, \"Input.dispatchKeyEvent\", {\n        type: \"keyUp\",\n        key: keyDef.key,\n        code: keyDef.code,\n        windowsVirtualKeyCode: keyDef.keyCode || 0,\n        nativeVirtualKeyCode: keyDef.keyCode || 0,","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/open-computer/services/interface-service/utils/cdp-input.js#L157-L193","documentation":"Thrown by the 'key' branch of cdp-input.js when process.argv[3] is falsy. The key action dispatches a single keyDown/keyUp pair using either a definition from the specialKeys map (Enter, Tab, Escape, arrows, etc.) or a synthesized {Key<UPPER>} definition, so a key name is mandatory.","triggerScenarios":"Running `node cdp-input.js key` with no key argument. The key must be a recognized special-key name or a single letter; an empty value cannot be mapped to a code.","commonSituations":"Caller passed an undefined key variable; the key name used a different casing than the specialKeys map (e.g. 'enter' vs 'Enter') — though that would not throw this error, it would synthesize a wrong code.","solutions":["Pass a key name: `node cdp-input.js key Enter`.","For special keys use the exact map names: Enter, Tab, Escape, Backspace, Delete, ArrowUp/Down/Left/Right, Home, End, PageUp, PageDown, Space.","In the caller, assert the key string is non-empty before spawning."],"exampleFix":"// before\nspawn('node', ['cdp-input.js', 'key']);\n// after\nspawn('node', ['cdp-input.js', 'key', 'Enter']);","handlingStrategy":"validation","validationCode":"if (typeof key !== 'string' || key.length === 0) {\n  throw new Error('A non-empty key name is required for key action');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use exact specialKeys names (Enter, Tab, Escape, ArrowUp, etc.).","Assert key is non-empty before spawning.","Document the key action's argv layout: key <key> [target_url]."],"tags":["cdp","browser-automation","argument-validation","keyboard"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}