{"record":{"id":"038487d3f9824447","repo":"Mintplex-Labs/anything-llm","slug":"type-requires-text-argument","errorCode":null,"errorMessage":"type requires <text> argument","messagePattern":"type requires <text> argument","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"open-computer/services/interface-service/utils/cdp-input.js","lineNumber":147,"sourceCode":"      }, sessionId);\n      await sleep(50);\n\n      // Press\n      await cdpSend(ws, \"Input.dispatchMouseEvent\", {\n        type: \"mousePressed\", x, y, button: \"left\", clickCount: 1\n      }, sessionId);\n      await sleep(30 + Math.floor(Math.random() * 40));\n\n      // Release\n      await cdpSend(ws, \"Input.dispatchMouseEvent\", {\n        type: \"mouseReleased\", x, y, button: \"left\", clickCount: 1\n      }, sessionId);\n\n      process.stdout.write(`clicked at (${x}, ${y})`);\n\n    } else if (action === \"type\") {\n      const text = process.argv[3];\n      if (!text) throw new Error(\"type requires <text> argument\");\n\n      // Type each character individually with realistic delays\n      for (let i = 0; i < text.length; i++) {\n        const char = text[i];\n\n        // dispatchKeyEvent with char sends the character as a trusted keyboard input\n        await cdpSend(ws, \"Input.dispatchKeyEvent\", {\n          type: \"keyDown\",\n          text: char,\n          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),","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/open-computer/services/interface-service/utils/cdp-input.js#L129-L165","documentation":"Thrown by the 'type' branch of cdp-input.js when process.argv[3] is falsy. The script needs a non-empty text string to iterate over and dispatch per-character keyDown/keyUp events, so an absent argument aborts before any CDP call.","triggerScenarios":"Running `node cdp-input.js type` with no third argument, or with an argument that the shell expanded to an empty string. Note argv[4] is the optional target_url for type, not the text.","commonSituations":"The text was stored in a variable that resolved to undefined and String()-coerced to 'undefined'-less empty; shell quoting dropped the value; the caller reused the click argument layout (which shifts positions).","solutions":["Pass the text as the third argument: `node cdp-input.js type \"hello world\"`.","Quote multi-word text so the shell delivers it as one argv entry.","In the caller, assert the text is a non-empty string before spawning."],"exampleFix":"// before\nspawn('node', ['cdp-input.js', 'type']);\n// after\nspawn('node', ['cdp-input.js', 'type', 'hello world']);","handlingStrategy":"validation","validationCode":"if (typeof text !== 'string' || text.length === 0) {\n  throw new Error('A non-empty text string is required for type action');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assert text is a non-empty string before spawning.","Quote multi-word text on the shell.","Remember type's argv layout: type <text> [target_url]."],"tags":["cdp","browser-automation","argument-validation","typing"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}