{"record":{"id":"17b097093a1120d3","repo":"Mintplex-Labs/anything-llm","slug":"click-requires-x-y-coordinates","errorCode":null,"errorMessage":"click requires <x> <y> coordinates","messagePattern":"click requires <x> <y> coordinates","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"open-computer/services/interface-service/utils/cdp-input.js","lineNumber":124,"sourceCode":"      const match = pages.find(\n        (p) => p.url.includes(targetUrl) || p.title.toLowerCase().includes(targetUrl.toLowerCase())\n      );\n      if (!match) {\n        const openTabs = pages.map((p) => `- ${p.title} ${p.url}`).join(\"\\n\");\n        throw new Error(`No browser tab matching \"${targetUrl}\". Open tabs:\\n${openTabs}`);\n      }\n      if (match) target = match;\n    }\n\n    const { sessionId } = await cdpSend(ws, \"Target.attachToTarget\", {\n      targetId: target.targetId,\n      flatten: true,\n    });\n\n    if (action === \"click\") {\n      const x = parseFloat(process.argv[3]);\n      const y = parseFloat(process.argv[4]);\n      if (isNaN(x) || isNaN(y)) throw new Error(\"click requires <x> <y> coordinates\");\n\n      // Move mouse to position first (triggers hover states)\n      await cdpSend(ws, \"Input.dispatchMouseEvent\", {\n        type: \"mouseMoved\", x, y\n      }, 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","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/open-computer/services/interface-service/utils/cdp-input.js#L106-L142","documentation":"cdp-input argument validation: for action 'click', parseFloat of argv[3] and argv[4] must both be finite numbers; if either is NaN the helper refuses to dispatch Input.dispatchMouseEvent. Coordinates are CSS pixels in the page's viewport, matching what Runtime.evaluate-based positioning would produce.","triggerScenarios":"Calling `node cdp-input.js click` with missing x/y, non-numeric x/y ('click abc def'), or swapped argument order where a filter string lands in argv[3]/argv[4]; passing empty strings.","commonSituations":"Automated callers building the command from variables that are undefined/empty; forgetting that click takes two coordinate args before the optional tab filter; copy-paste from a type invocation keeping the old arg layout.","solutions":["Pass two finite numbers: node cdp-input.js click <x> <y> [tabFilter]","Validate/guard in the calling code that x and y are numbers before spawning the helper","If coordinates come from a prior screenshot/eval step, make sure they are pixels (numbers), not percentage strings or empty values"],"exampleFix":"// before\nspawn('node', ['cdp-input.js', 'click', String(x), String(y ?? '')])\n// after\nif (!Number.isFinite(x) || !Number.isFinite(y)) throw new Error('need numeric x,y');\nspawn('node', ['cdp-input.js', 'click', String(x), String(y)])","handlingStrategy":"validation","validationCode":"function validClickArgs(x, y) {\n  const nx = Number(x), ny = Number(y);\n  return Number.isFinite(nx) && Number.isFinite(ny);\n}\nif (!validClickArgs(process.argv[3], process.argv[4])) { console.error('usage: cdp-input.js click <x> <y> [tabFilter]'); process.exit(2); }","typeGuard":"function isFiniteCoords(x: unknown, y: unknown): x is number & number extends never ? never : number {\n  return Number.isFinite(Number(x)) && Number.isFinite(Number(y));\n}","tryCatchPattern":"try { await sendInput('click', x, y); } catch (e) { if (/click requires <x> <y> coordinates/.test(e.message)) { /* fix argument production upstream — do not retry unchanged */ } else throw e; }","preventionTips":["Check Number.isFinite on both coordinates before spawning the helper — it only validates after connecting","Log the exact argv array in wrappers when input commands fail, positional bugs are the usual cause","Source coordinates from the same viewport context that rendered them (CSS px vs device px with DPR)"],"tags":["chrome","cdp","click","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"}