{"record":{"id":"2b58634227ee8662","repo":"jackwener/OpenCLI","slug":"midjourney-creation-action-unavailable-target","errorCode":null,"errorMessage":"Midjourney Creation Action unavailable: ${target?.reason || text}","messagePattern":"Midjourney Creation Action unavailable: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":1219,"sourceCode":"  const target = unwrapEvaluateResult(await page.evaluate((label, wantedIndex) => {\n    const visible = (element) => {\n      const rect = element.getBoundingClientRect();\n      const style = getComputedStyle(element);\n      return rect.width > 0 && rect.height > 0 && style.visibility !== 'hidden' && style.display !== 'none';\n    };\n    const close = [...document.querySelectorAll('button[title=\"Close\"]')].filter(visible).at(-1);\n    const scope = close?.parentElement?.parentElement;\n    if (!scope) return { ok: false, reason: 'job detail scope not found' };\n    const matches = [...scope.querySelectorAll('button')]\n      .filter(visible)\n      .filter((button) => String(button.textContent || '').replace(/\\s+/g, ' ').trim() === label);\n    const button = matches[wantedIndex];\n    if (!button) return { ok: false, reason: `button ${label} occurrence ${wantedIndex} not found`, count: matches.length };\n    if (button.disabled) return { ok: false, reason: `button ${label} is disabled`, count: matches.length };\n    const rect = button.getBoundingClientRect();\n    return { ok: true, x: rect.left + rect.width / 2, y: rect.top + rect.height / 2, count: matches.length };\n  }, normalizeButtonText(text), occurrence));\n  if (!target?.ok) throw new CommandExecutionError(`Midjourney Creation Action unavailable: ${target?.reason || text}`);\n  if (typeof page.nativeClick !== 'function') throw new CommandExecutionError('Browser Bridge native click support is required for Creation Actions');\n  await page.nativeClick(target.x, target.y);\n  return target;\n}\n\nexport async function clickVisibleControl(page, label) {\n  const target = unwrapEvaluateResult(await page.evaluate((wanted) => {\n    const visible = (element) => {\n      const rect = element.getBoundingClientRect();\n      return rect.width > 0 && rect.height > 0 && getComputedStyle(element).display !== 'none';\n    };\n    const button = [...document.querySelectorAll('button')].find((node) => visible(node) && (\n      node.textContent?.trim().replace(/\\s+/g, ' ') === wanted\n      || node.title === wanted\n      || node.getAttribute('aria-label') === wanted\n    ));\n    if (!button || button.disabled) return null;\n    const rect = button.getBoundingClientRect();","sourceCodeStart":1201,"sourceCodeEnd":1237,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L1201-L1237","documentation":"CommandExecutionError thrown when the in-page button lookup for a Creation Action fails: the labeled button occurrence was not found or is disabled. target?.reason explains which (e.g. 'button Create occurrence 2 not found', 'button Create is disabled'); falls back to the search text.","triggerScenarios":"clickCreationAction(page, label, occurrence) when fewer buttons match than the requested occurrence index, or the matched button has disabled=true.","commonSituations":"Requesting occurrence 2 of 'Create' when only one exists; job still running so the action button is disabled; Midjourney changed button labels; composer not open.","solutions":["Reduce the occurrence index or verify how many matching buttons exist (target.count in reason).","Wait for the current job to finish before clicking disabled action buttons.","Verify button label text against the live UI and update the call.","Reload the page and ensure the composer/creation view is open."],"exampleFix":"// before\nawait clickCreationAction(page, 'Create', 2);\n// after\nconst count = await countButtons(page, 'Create');\nif (count > 1) await clickCreationAction(page, 'Create', 1);","handlingStrategy":"validation","validationCode":"const count = await page.evaluate((label) =>\n  [...document.querySelectorAll('button')].filter(b => b.textContent?.trim() === label).length, 'Create');\nif (occurrence >= count) throw new Error(`Only ${count} matching buttons`);","typeGuard":null,"tryCatchPattern":"try {\n  await clickCreationAction(page, 'Create', idx);\n} catch (err) {\n  if (String(err.message).includes('unavailable')) {\n    await page.wait(3); // job may still be running\n    await clickCreationAction(page, 'Create', 0);\n  } else throw err;\n}","preventionTips":["Use occurrence index 0 unless you know multiple buttons exist","Wait for running jobs to finish before clicking actions","Verify button labels against current UI","Handle disabled buttons with retries"],"tags":["midjourney","button","dom","ui-automation"],"backgroundTag":"button-not-clickable","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}