{"record":{"id":"093ffda055abee73","repo":"jackwener/OpenCLI","slug":"setfileinput-returned-no-count-command-may-not-b","errorCode":null,"errorMessage":"setFileInput returned no count — command may not be supported by the extension","messagePattern":"setFileInput returned no count — command may not be supported by the extension","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/browser/page.ts","lineNumber":316,"sourceCode":"      timeoutMs,\n      ...this._cmdOpts(),\n    });\n    return result as BrowserDownloadWaitResult;\n  }\n\n  /**\n   * Set local file paths on a file input element via CDP DOM.setFileInputFiles.\n   * Chrome reads the files directly from the local filesystem, avoiding the\n   * payload size limits of base64-in-evaluate.\n   */\n  async setFileInput(files: string[], selector?: string): Promise<void> {\n    const result = await sendCommand('set-file-input', {\n      files,\n      selector,\n      ...this._cmdOpts(),\n    }) as { count?: number };\n    if (!result?.count) {\n      throw new Error('setFileInput returned no count — command may not be supported by the extension');\n    }\n  }\n\n  async insertText(text: string): Promise<void> {\n    const result = await sendCommand('insert-text', {\n      text,\n      ...this._cmdOpts(),\n    }) as { inserted?: boolean };\n    if (!result?.inserted) {\n      throw new Error('insertText returned no inserted flag — command may not be supported by the extension');\n    }\n  }\n\n  async frames(): Promise<Array<{ index: number; frameId: string; url: string; name: string }>> {\n    const result = await sendCommand('frames', { ...this._cmdOpts() });\n    return Array.isArray(result) ? result : [];\n  }\n","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/src/browser/page.ts#L298-L334","documentation":"setFileInput sends the 'set-file-input' command through the Chrome extension bridge and expects a result containing a numeric count of matched inputs. If the count is missing or 0, it assumes the connected extension does not implement the command and throws.","triggerScenarios":"Calling page.setFileInput(files, selector) when the extension responds with a result lacking a truthy count — either an older extension version without set-file-input support, or the selector matching no inputs.","commonSituations":"Extension not updated after OpenCLI upgrade added set-file-input; selector matches zero file inputs on the page; result shape changed between extension versions.","solutions":["Update the OpenCLI Chrome extension to the latest version and reload it in chrome://extensions","Check that the selector matches at least one file input element on the page","Fall back to CDP DOM.setFileInputFiles as an alternative path"],"exampleFix":"// before\nawait page.setFileInput('/tmp/upload.png', 'input[type=file]');\n// after: guard against unsupported extension\nconst inputs = await page.evaluate(\"document.querySelectorAll('input[type=file]').length\");\nif (inputs > 0) await page.setFileInput('/tmp/upload.png', 'input[type=file]');","handlingStrategy":"fallback","validationCode":"const inputCount = await page.evaluate(\"document.querySelectorAll('input[type=file]').length\");\nif (inputCount === 0) throw new Error('no file inputs match');","typeGuard":"function supportsSetFileInput(r: { count?: number } | null): r is { count: number } {\n  return typeof r?.count === 'number' && r.count > 0;\n}","tryCatchPattern":"try { await page.setFileInput(files, sel); }\ncatch (e) {\n  if (String(e.message).includes('no count')) {\n    // fallback: CDP DOM.setFileInputFiles\n  } else throw e;\n}","preventionTips":["Keep the Chrome extension version in sync with the CLI","Verify the selector matches a file input before calling","Reload the extension after CLI upgrades"],"tags":["extension","browser-automation","version-compatibility"],"backgroundTag":"unsupported-command","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}