jackwener/OpenCLI · error · CommandExecutionError

Instagram upload input not found

Error message

Instagram upload input not found

What it means

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.

Source

Thrown at clis/instagram/post.js:434

      const primary = visibleDialogInputs.length
        ? [visibleDialogInputs[visibleDialogInputs.length - 1]]
        : dialogInputs.length
          ? [dialogInputs[dialogInputs.length - 1]]
          : [];
      const ordered = [...primary, ...pickerInputs, ...candidates]
        .filter((el, index, arr) => arr.indexOf(el) === index);
      if (!ordered.length) return { ok: false };

      document.querySelectorAll('[data-opencli-ig-upload-index]').forEach((el) => el.removeAttribute('data-opencli-ig-upload-index'));
      const selectors = ordered.map((input, index) => {
        input.setAttribute('data-opencli-ig-upload-index', String(index));
        return '[data-opencli-ig-upload-index="' + index + '"]';
      });
      return { ok: true, selectors };
    })(${JSON.stringify(includesVideo)})
  `);
    if (!result?.ok || !result.selectors?.length) {
        throw new CommandExecutionError('Instagram upload input not found', 'Open the new-post composer in a logged-in browser session and retry');
    }
    return result.selectors;
}
async function resolveUploadSelectors(page, mediaItems) {
    try {
        return await findUploadSelectors(page, mediaItems);
    }
    catch (error) {
        if (!(error instanceof CommandExecutionError) || !error.message.includes('upload input not found')) {
            throw error;
        }
        await ensureComposerOpen(page);
        await page.wait({ time: 1.5 });
        try {
            return await findUploadSelectors(page, mediaItems);
        }
        catch (retryError) {
            if (!(retryError instanceof CommandExecutionError) || !retryError.message.includes('upload input not found')) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the browser session is logged into Instagram and navigate to the new-post composer before retrying
  2. Take a screenshot of the current page to confirm which screen the browser is actually on
  3. Update the CLI to the latest version in case Instagram changed composer markup
  4. Retry after a short wait so a slow-rendering composer has time to mount the input

Example fix

// before
await postToInstagram(page, mediaPaths);
// after
await page.goto('https://www.instagram.com/');
if (!page.url().includes('instagram.com')) throw new Error('not on Instagram');
await page.wait({ time: 2 }); // let composer render
await postToInstagram(page, mediaPaths);
Defensive patterns

Strategy: retry

Validate before calling

const state = await page.evaluate(() => !!document.querySelector('input[type=file]'));
if (!state) { await page.wait({ time: 2 }); }

Type guard

function isSelectorList(v) { return Array.isArray(v) && v.length > 0 && v.every(s => typeof s === 'string'); }

Try / catch

try {
  const selectors = await resolveUploadSelectors(page, mediaItems);
} catch (e) {
  if (String(e.message).includes('upload input not found')) {
    await page.screenshot({ path: '/tmp/precheck.png' });
    await page.wait({ time: 2 });
    return resolveUploadSelectors(page, mediaItems); // retry once
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/a31a7e2db2d34dab. Report an issue: GitHub.