Mintplex-Labs/anything-llm · error
type requires argument
Error message
type requires <text> argument
What it means
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.
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
Example fix
# before node cdp-input.js type $USER_INPUT # empty var -> argv[3] missing # after node cdp-input.js type "$USER_INPUT" # or guard: [ -n "$USER_INPUT" ] && ...
Defensive patterns
Strategy: validation
Validate before calling
const text = process.argv[3];
if (typeof text !== 'string' || text.length === 0) { console.error('usage: cdp-input.js type <text> [tabFilter]'); process.exit(2); } Type guard
function isNonEmptyString(s: unknown): s is string { return typeof s === 'string' && s.length > 0; } Try / catch
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; } Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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).
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- click requires coordinates
- key requires argument (e.g. Enter, Tab, Escape)
- No browser tab matching
- No browser pages open.
- No browser pages open.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/038487d3f9824447.
Report an issue: GitHub.
Appendix: source
Thrown at open-computer/services/interface-service/utils/cdp-input.js:147
}, sessionId);
await sleep(50);
// Press
await cdpSend(ws, "Input.dispatchMouseEvent", {
type: "mousePressed", x, y, button: "left", clickCount: 1
}, sessionId);
await sleep(30 + Math.floor(Math.random() * 40));
// Release
await cdpSend(ws, "Input.dispatchMouseEvent", {
type: "mouseReleased", x, y, button: "left", clickCount: 1
}, sessionId);
process.stdout.write(`clicked at (${x}, ${y})`);
} else if (action === "type") {
const text = process.argv[3];
if (!text) throw new Error("type requires <text> argument");
// Type each character individually with realistic delays
for (let i = 0; i < text.length; i++) {
const char = text[i];
// dispatchKeyEvent with char sends the character as a trusted keyboard input
await cdpSend(ws, "Input.dispatchKeyEvent", {
type: "keyDown",
text: char,
key: char,
code: charToCode(char),
unmodifiedText: char,
}, sessionId);
await cdpSend(ws, "Input.dispatchKeyEvent", {
type: "keyUp",
key: char,
code: charToCode(char),View on GitHub (pinned to 3aec848f28)