{"record":{"id":"d5abc5010477cdd0","repo":"jackwener/OpenCLI","slug":"instagram-posting-requires-browser-bridge-file-upl","errorCode":null,"errorMessage":"Instagram posting requires Browser Bridge file upload support","messagePattern":"Instagram posting requires Browser Bridge file upload support","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/post.js","lineNumber":615,"sourceCode":"      return { state: 'pending', detail: dialogText || '' };\n    })()\n  `;\n}\nasync function inspectUploadStage(page) {\n    const result = await page.evaluate(buildInspectUploadStageJs());\n    if (result?.state)\n        return result;\n    if (result?.ok === true)\n        return { state: 'preview', detail: result.detail };\n    return { state: 'pending', detail: result?.detail };\n}\nfunction makeUploadFailure(detail) {\n    return new CommandExecutionError('Instagram image upload failed', detail ? `Instagram rejected the upload: ${detail}` : 'Instagram rejected the upload before the preview stage');\n}\nasync function uploadMedia(page, mediaItems, selector) {\n    const mediaPaths = mediaItems.map((item) => item.filePath);\n    if (!page.setFileInput) {\n        throw new CommandExecutionError('Instagram posting requires Browser Bridge file upload support', 'Use Browser Bridge or another browser mode that supports setFileInput');\n    }\n    let activeSelector = selector;\n    for (let attempt = 0; attempt < 2; attempt++) {\n        try {\n            await page.setFileInput(mediaPaths, activeSelector);\n            await dispatchUploadEvents(page, activeSelector);\n            return;\n        }\n        catch (error) {\n            const message = error instanceof Error ? error.message : String(error);\n            const staleSelector = message.includes('No element found matching selector')\n                || message.includes('Could not find node with given id')\n                || message.includes('No node with given id found');\n            if (staleSelector && attempt === 0) {\n                activeSelector = await resolveFreshUploadSelector(page, activeSelector, mediaItems);\n                continue;\n            }\n            if (!message.includes('Unknown action') && !message.includes('set-file-input') && !message.includes('not supported')) {","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/post.js#L597-L633","documentation":"uploadMedia requires page.setFileInput to attach media files to the composer's file input. When the connected browser driver does not implement setFileInput, the library throws immediately with this message instead of attempting a doomed upload. It is an environment-capability check, not a page-state failure.","triggerScenarios":"Calling executeUiInstagramPost with a page object whose prototype lacks setFileInput — e.g. a plain Puppeteer/Playwright page or a driver mode other than Browser Bridge.","commonSituations":"Launching the CLI in a headless/CDP mode that skips Browser Bridge, using an older driver version predating setFileInput, or pointing the tool at a remote browser that does not expose the extension.","solutions":["Switch to Browser Bridge mode so the page object exposes setFileInput","Update the browser driver/CLI to a version that implements setFileInput","Confirm the active browser mode with the CLI's mode/diagnostics command before posting"],"exampleFix":"// before\nconst page = await plainPuppeteerLaunch();\nawait postImage(page, 'photo.jpg');\n// after\nconst page = await launchBrowserBridge(); // provides page.setFileInput\nawait postImage(page, 'photo.jpg');","handlingStrategy":"validation","validationCode":"if (typeof page.setFileInput !== 'function') {\n  throw new Error('Current browser mode lacks setFileInput; enable Browser Bridge before posting');\n}","typeGuard":"function supportsFileUpload(page) { return typeof page.setFileInput === 'function'; }","tryCatchPattern":"try {\n  await postImage(page, file);\n} catch (e) {\n  if (String(e.message).includes('Browser Bridge file upload support')) {\n    console.error('Relaunch the CLI in Browser Bridge mode and retry.');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Check page.setFileInput existence at startup and fail fast with a clear message","Pin the CLI/driver version that provides setFileInput in your environment","Document the required browser mode in your posting wrapper"],"tags":["instagram","browser-bridge","api-capability"],"backgroundTag":"api-not-supported","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}