{"record":{"id":"a31a7e2db2d34dab","repo":"jackwener/OpenCLI","slug":"instagram-upload-input-not-found","errorCode":null,"errorMessage":"Instagram upload input not found","messagePattern":"Instagram upload input not found","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/post.js","lineNumber":434,"sourceCode":"      const primary = visibleDialogInputs.length\n        ? [visibleDialogInputs[visibleDialogInputs.length - 1]]\n        : dialogInputs.length\n          ? [dialogInputs[dialogInputs.length - 1]]\n          : [];\n      const ordered = [...primary, ...pickerInputs, ...candidates]\n        .filter((el, index, arr) => arr.indexOf(el) === index);\n      if (!ordered.length) return { ok: false };\n\n      document.querySelectorAll('[data-opencli-ig-upload-index]').forEach((el) => el.removeAttribute('data-opencli-ig-upload-index'));\n      const selectors = ordered.map((input, index) => {\n        input.setAttribute('data-opencli-ig-upload-index', String(index));\n        return '[data-opencli-ig-upload-index=\"' + index + '\"]';\n      });\n      return { ok: true, selectors };\n    })(${JSON.stringify(includesVideo)})\n  `);\n    if (!result?.ok || !result.selectors?.length) {\n        throw new CommandExecutionError('Instagram upload input not found', 'Open the new-post composer in a logged-in browser session and retry');\n    }\n    return result.selectors;\n}\nasync function resolveUploadSelectors(page, mediaItems) {\n    try {\n        return await findUploadSelectors(page, mediaItems);\n    }\n    catch (error) {\n        if (!(error instanceof CommandExecutionError) || !error.message.includes('upload input not found')) {\n            throw error;\n        }\n        await ensureComposerOpen(page);\n        await page.wait({ time: 1.5 });\n        try {\n            return await findUploadSelectors(page, mediaItems);\n        }\n        catch (retryError) {\n            if (!(retryError instanceof CommandExecutionError) || !retryError.message.includes('upload input not found')) {","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/post.js#L416-L452","documentation":"findUploadSelectors evaluates in-browser JS to collect file-input selectors for the new-post composer. If the browser-side probe returns not-ok or an empty selector list, the library assumes no upload input is present in the DOM and throws this CommandExecutionError. It guards the rest of the posting pipeline from running against a page that cannot accept files.","triggerScenarios":"Calling executeUiInstagramPost (via resolveUploadSelectors -> findUploadSelectors) when the evaluated page DOM contains no matching file input element — i.e. result.ok is false or result.selectors is empty.","commonSituations":"Not on the new-post composer page (still on feed or login screen), session logged out or cookie expired, Instagram A/B redesign renaming the input selector, or the composer dialog not yet rendered when the probe runs.","solutions":["Verify the browser session is logged into Instagram and navigate to the new-post composer before retrying","Take a screenshot of the current page to confirm which screen the browser is actually on","Update the CLI to the latest version in case Instagram changed composer markup","Retry after a short wait so a slow-rendering composer has time to mount the input"],"exampleFix":"// before\nawait postToInstagram(page, mediaPaths);\n// after\nawait page.goto('https://www.instagram.com/');\nif (!page.url().includes('instagram.com')) throw new Error('not on Instagram');\nawait page.wait({ time: 2 }); // let composer render\nawait postToInstagram(page, mediaPaths);","handlingStrategy":"retry","validationCode":"const state = await page.evaluate(() => !!document.querySelector('input[type=file]'));\nif (!state) { await page.wait({ time: 2 }); }","typeGuard":"function isSelectorList(v) { return Array.isArray(v) && v.length > 0 && v.every(s => typeof s === 'string'); }","tryCatchPattern":"try {\n  const selectors = await resolveUploadSelectors(page, mediaItems);\n} catch (e) {\n  if (String(e.message).includes('upload input not found')) {\n    await page.screenshot({ path: '/tmp/precheck.png' });\n    await page.wait({ time: 2 });\n    return resolveUploadSelectors(page, mediaItems); // retry once\n  }\n  throw e;\n}","preventionTips":["Always land on the new-post composer and confirm login before posting","Add a small wait after opening the composer so inputs finish rendering","Check session validity (cookies/login state) at the start of each run"],"tags":["instagram","dom-selector","browser-automation"],"backgroundTag":"selector-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}