{"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":"exception","errorClass":null,"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/3aec848f2885144aa8f1e53b9731a04310d5d558/open-computer/services/interface-service/utils/cdp-input.js#L129-L165","documentation":"cdp-input argument validation for action 'type': argv[3] must be a non-empty string; the helper types it character by character with randomized human-like delays via Input.dispatchKeyEvent (keyDown with text, then keyUp). An empty/missing text argument aborts before any keystroke is sent.","triggerScenarios":"Running `node cdp-input.js type` with no text argument, an empty string argument, or an argument that shell-expansion swallowed (unquoted empty variable: type \"\" or type $EMPTY).","commonSituations":"Calling scripts pass an unset variable ($TEXT with TEXT empty) which bash drops entirely; quoting mistakes; intentional empty-string clears being unsupported (use key Backspace instead).","solutions":["Pass the text as a single quoted argument: node cdp-input.js type 'hello world' [tabFilter]","Quote shell variables in the caller: \"type\" \"$TEXT\" so empty expands visibly and can be caught upstream","To clear a field, use key presses (Ctrl+A / Backspace) rather than an empty type call"],"exampleFix":"# before\nnode cdp-input.js type $USER_INPUT        # empty var -> argv[3] missing\n# after\nnode cdp-input.js type \"$USER_INPUT\"      # or guard: [ -n \"$USER_INPUT\" ] && ...","handlingStrategy":"validation","validationCode":"const text = process.argv[3];\nif (typeof text !== 'string' || text.length === 0) { console.error('usage: cdp-input.js type <text> [tabFilter]'); process.exit(2); }","typeGuard":"function isNonEmptyString(s: unknown): s is string { return typeof s === 'string' && s.length > 0; }","tryCatchPattern":"try { await sendInput('type', text); } catch (e) { if (/type requires <text> argument/.test(e.message)) { /* caller bug: fix text production, never retry empty */ } else throw e; }","preventionTips":["Always quote the text argument (and any shell-expanded variables) when invoking the helper","Guard `[ -n \"$TEXT\" ]` in shell wrappers before dispatching","Use key Backspace/Ctrl+A flows for clearing fields — empty type calls are invalid by design"],"tags":["chrome","cdp","typing","cli-args","validation","open-computer"],"backgroundTag":"invalid-cli-argument","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}