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
- 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
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
- 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
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
- Instagram reel caption editor did not appear
- Waiting for 12306 tk auth cookie
- ChatGPT composer is not available on the current page.
- Could not find the ChatGPT model selector in the composer.
- Could not click the ChatGPT ${target.label} model option.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a31a7e2db2d34dab.
Report an issue: GitHub.