jackwener/OpenCLI · error · CommandExecutionError
Could not locate Midjourney ${slotLabel} slot after upload
Error message
Could not locate Midjourney ${slotLabel} slot after upload What it means
Thrown when markReferenceTarget cannot find the target drop area (slot) for the given slotLabel after uploading a reference image. The in-page evaluate returns {ok:false, source:true, target:false} because no matching slot element was located in the Midjourney composer.
Source
Thrown at clis/midjourney/utils.js:1069
document.querySelectorAll('[data-opencli-ref-source],[data-opencli-ref-target]').forEach((el) => {
el.removeAttribute('data-opencli-ref-source');
el.removeAttribute('data-opencli-ref-target');
});
const source = [...document.querySelectorAll('img[src]')].find((img) => img.src === url);
const labelNode = [...document.querySelectorAll('div,span')].find((node) => node.children.length === 0 && node.textContent?.trim() === label);
if (!source || !labelNode) return { ok: false, source: Boolean(source), target: Boolean(labelNode) };
let target = labelNode.parentElement;
while (target && target.parentElement) {
const rect = target.getBoundingClientRect();
if (rect.width >= 120 && rect.height >= 45) break;
target = target.parentElement;
}
if (!target) return { ok: false, source: true, target: false };
source.setAttribute('data-opencli-ref-source', '1');
target.setAttribute('data-opencli-ref-target', '1');
return { ok: true };
}, sourceUrl, slotLabel));
if (!result?.ok) throw new CommandExecutionError(`Could not locate Midjourney ${slotLabel} slot after upload`);
}
async function verifyReferenceTarget(page, slotLabel) {
const assigned = unwrapEvaluateResult(await page.evaluate((label) => {
const labelNode = [...document.querySelectorAll('div,span')]
.find((node) => node.children.length === 0 && node.textContent?.trim() === label);
if (!labelNode) return false;
const peerLabels = ['Image Prompts', 'Style References', 'Omni Reference'].filter((item) => item !== label);
let target = labelNode;
for (let depth = 0; depth < 8 && target?.parentElement; depth += 1) {
target = target.parentElement;
const text = target.textContent || '';
if (peerLabels.some((peer) => text.includes(peer))) break;
const empty = [...target.querySelectorAll('div')]
.some((node) => /^Select images? below$/i.test(node.textContent?.trim() || ''));
if (!empty && target.querySelector('button,img')) return true;
}
return false;View on GitHub (pinned to 49907e53dc)
Solutions
- Ensure openImagePanel(page) ran and the image panel is visible before marking slots.
- Log/dump the slot DOM to verify the current slot label text and update slotLabel mapping.
- Add a wait/retry before evaluate so the slot element has rendered.
- Reload the Midjourney page and open a fresh composer.
Example fix
// before await markReferenceTarget(page, url, label); // after await openImagePanel(page); await page.wait(1); await markReferenceTarget(page, url, label);
Defensive patterns
Strategy: validation
Validate before calling
const hasSlot = await page.evaluate((label) =>
[...document.querySelectorAll('div,span')].some(n => n.textContent?.trim() === label), slotLabel);
if (!hasSlot) await openImagePanel(page); Try / catch
try {
await markReferenceTarget(page, url, label);
} catch (err) {
if (String(err.message).includes('Could not locate')) {
await openImagePanel(page);
await markReferenceTarget(page, url, label);
} else throw err;
} Prevention
- Always open the image panel first
- Verify slot label text against the live UI
- Add waits for panel rendering
- Reload the page if slots are missing
When it happens
Trigger: Calling uploadReferencesToSlot / markReferenceTarget when the reference slot panel is closed, the slot label changed, or the panel DOM has not rendered yet.
Common situations: Image panel not opened before marking; Midjourney renamed slot labels (e.g. 'Style References'); slow rendering so slots are absent; page in a different state (no draft open).
Related errors
- Midjourney reference upload fallback failed: ${result?.reaso
- Visible Midjourney control "${label}" was not found
- DOM node not found
- NO_DIALOG
- Could not find Antigravity input box
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7d94bbe198ad856a.
Report an issue: GitHub.