{"record":{"id":"69684d44d669bf19","repo":"jackwener/OpenCLI","slug":"omni-reference-accepts-exactly-one-local-image","errorCode":null,"errorMessage":"Omni Reference accepts exactly one local image","messagePattern":"Omni Reference accepts exactly one local image","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":1185,"sourceCode":"  const selected = await uploadReferenceLibrary(page, localPaths);\n\n  // Uploading while the persistent composer retained a video state can leave\n  // the library open beside Start/End Frame slots. Reassert image mode before\n  // assigning image-generation references; End Frame intentionally stays in\n  // the manual video composer.\n  if (slot !== 'end') {\n    await ensureImageComposer(page);\n    await openImagePanel(page);\n  }\n\n  const label = slot === 'style'\n    ? 'Style References'\n    : slot === 'end'\n      ? 'End Frame'\n      : slot === 'image'\n        ? 'Image Prompts'\n        : 'Omni Reference';\n  if (slot === 'omni' && selected.length !== 1) throw new ArgumentError('Omni Reference accepts exactly one local image');\n  if (typeof page.drag !== 'function') throw new CommandExecutionError('Browser Bridge does not support Reference drag-and-drop');\n  for (const url of selected) {\n    await markReferenceTarget(page, url, label);\n    await page.drag('[data-opencli-ref-source=\"1\"]', '[data-opencli-ref-target=\"1\"]');\n    await page.wait(0.8);\n    await verifyReferenceTarget(page, label);\n  }\n  return selected;\n}\n\nfunction normalizeButtonText(value) {\n  return String(value || '').replace(/\\s+/g, ' ').trim();\n}\n\nexport async function clickCreationAction(page, text, occurrence = 0) {\n  const target = unwrapEvaluateResult(await page.evaluate((label, wantedIndex) => {\n    const visible = (element) => {\n      const rect = element.getBoundingClientRect();","sourceCodeStart":1167,"sourceCodeEnd":1203,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L1167-L1203","documentation":"ArgumentError thrown when the 'omni' slot is targeted but the caller supplied a number of local images other than exactly one. Omni Reference accepts a single image by design.","triggerScenarios":"uploadReferencesToSlot(page, paths, 'omni') with paths.length === 0 or paths.length >= 2.","commonSituations":"Passing an array of style/character images to the omni slot by mistake; reusing a batch-upload helper for omni references; empty array when upload failed earlier.","solutions":["Pass exactly one image path for the omni slot.","For multiple images, split calls or use the image/style reference slots instead.","Validate the array length before calling uploadReferencesToSlot."],"exampleFix":"// before\nawait uploadReferencesToSlot(page, [a, b], 'omni');\n// after\nawait uploadReferencesToSlot(page, [a], 'omni');","handlingStrategy":"validation","validationCode":"if (slot === 'omni' && localPaths.length !== 1) {\n  throw new Error('Omni Reference requires exactly one image path');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await uploadReferencesToSlot(page, paths, 'omni');\n} catch (err) {\n  if (String(err.message).includes('exactly one')) {\n    console.error('Pass a single-element array for omni slot');\n  } else throw err;\n}","preventionTips":["Validate input arrays per slot type","Keep omni uploads separate from batch uploads","Document slot arity requirements in calling code"],"tags":["midjourney","argument-validation","api-misuse"],"backgroundTag":"invalid-argument-count","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}