{"record":{"id":"9a34789d7f789b92","repo":"jackwener/OpenCLI","slug":"midjourney-slotlabel-reference-assignment-was-n","errorCode":null,"errorMessage":"Midjourney ${slotLabel} reference assignment was not verified","messagePattern":"Midjourney (.+?) reference assignment was not verified","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":1089,"sourceCode":"\nasync function verifyReferenceTarget(page, slotLabel) {\n  const assigned = unwrapEvaluateResult(await page.evaluate((label) => {\n    const labelNode = [...document.querySelectorAll('div,span')]\n      .find((node) => node.children.length === 0 && node.textContent?.trim() === label);\n    if (!labelNode) return false;\n    const peerLabels = ['Image Prompts', 'Style References', 'Omni Reference'].filter((item) => item !== label);\n    let target = labelNode;\n    for (let depth = 0; depth < 8 && target?.parentElement; depth += 1) {\n      target = target.parentElement;\n      const text = target.textContent || '';\n      if (peerLabels.some((peer) => text.includes(peer))) break;\n      const empty = [...target.querySelectorAll('div')]\n        .some((node) => /^Select images? below$/i.test(node.textContent?.trim() || ''));\n      if (!empty && target.querySelector('button,img')) return true;\n    }\n    return false;\n  }, slotLabel));\n  if (!assigned) throw new CommandExecutionError(`Midjourney ${slotLabel} reference assignment was not verified`);\n}\n\nexport async function uploadReferenceLibrary(page, localPaths) {\n  if (!localPaths.length) return [];\n  await openImagePanel(page);\n  const beforeSources = await visibleImageSources(page);\n  const before = new Set(beforeSources);\n  let captureReady = false;\n  if (typeof page.installInterceptor === 'function'\n    && typeof page.getInterceptedRequests === 'function'\n    && typeof page.waitForCapture === 'function') {\n    try {\n      await page.installInterceptor('/api/storage-upload-file');\n      await page.getInterceptedRequests();\n      captureReady = true;\n    } catch {}\n  }\n  let uploaded = false;","sourceCodeStart":1071,"sourceCodeEnd":1107,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L1071-L1107","documentation":"Thrown when verifyReferenceTarget cannot confirm the dragged image actually landed in the labeled slot. The in-page check looks for the labeled slot containing a button/img and not showing the 'Select image(s) below' placeholder; if it still looks empty, assignment is deemed unverified.","triggerScenarios":"After page.drag of the marked source onto the marked target, the slot still displays its placeholder; drag event was not accepted by the app; verification ran too soon (0.8s wait insufficient).","commonSituations":"Slow network so the uploaded thumbnail hasn't rendered; Midjourney's drop handler rejects synthetic drag events; the drag landed on the wrong slot; label matched multiple nodes.","solutions":["Increase the post-drag wait (page.wait) or implement polling until verifyReferenceTarget returns true.","Verify the drag coordinates/hit target; use native drag events if the Bridge supports them.","Check that the uploaded image URL actually appears in the visible image sources before verifying.","Retry the drag once, then fall back to the file-input upload path."],"exampleFix":"// before\nawait page.drag('[data-opencli-ref-source=\"1\"]', '[data-opencli-ref-target=\"1\"]');\nawait page.wait(0.8);\nawait verifyReferenceTarget(page, label);\n// after\nawait page.drag('[data-opencli-ref-source=\"1\"]', '[data-opencli-ref-target=\"1\"]');\nfor (let i = 0; i < 5; i++) {\n  await page.wait(1);\n  try { await verifyReferenceTarget(page, label); break; } catch {}\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await verifyReferenceTarget(page, label);\n} catch (err) {\n  if (String(err.message).includes('not verified')) {\n    await page.wait(2);\n    await verifyReferenceTarget(page, label);\n  } else throw err;\n}","preventionTips":["Wait/poll after drag instead of a fixed short delay","Confirm the uploaded thumbnail is rendered before verifying","Ensure the drag targets the correct slot","Retry the drag once before failing"],"tags":["midjourney","drag-and-drop","verification","browser-automation"],"backgroundTag":"drag-drop-verification-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}