{"record":{"id":"7acff4e34cc59606","repo":"jackwener/OpenCLI","slug":"could-not-set-midjourney-anchortext-target","errorCode":null,"errorMessage":"Could not set Midjourney ${anchorText}: ${target?.reason || targetText}","messagePattern":"Could not set Midjourney (.+?): (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":1430,"sourceCode":"    for (let depth = 0; depth < 7 && root; depth += 1, root = root.parentElement) {\n      const buttons = [...root.querySelectorAll('button')].filter(visible);\n      const matching = buttons.filter((button) => values.includes(button.textContent?.trim()));\n      if (matching.length >= Math.min(2, values.length)) {\n        const button = matching.find((item) => item.textContent?.trim() === wanted);\n        if (!button) return { ok: false, reason: `${wanted} option not found` };\n        if (button.disabled) return { ok: false, reason: `${wanted} option is disabled` };\n        const selected = button.getAttribute('aria-pressed') === 'true'\n          || button.getAttribute('aria-checked') === 'true'\n          || ['active', 'checked', 'on'].includes(button.getAttribute('data-state'))\n          || String(button.className).includes('text-splash');\n        if (selected) return { ok: true, changed: false };\n        button.setAttribute('data-opencli-setting-target', '1');\n        return { ok: true, changed: true };\n      }\n    }\n    return { ok: false, reason: `${anchorLabel} setting group not found` };\n  }, anchorText, candidates, targetText));\n  if (!target?.ok) throw new CommandExecutionError(`Could not set Midjourney ${anchorText}: ${target?.reason || targetText}`);\n  if (target.changed) {\n    await page.click('[data-opencli-setting-target=\"1\"]');\n    await page.wait(0.4);\n    const verified = await readSiteSettings(page);\n    const selected = anchorText === 'Video Resolution'\n      ? String(verified.videoResolution || '').toUpperCase()\n      : anchorText === 'Video Batch Size'\n        ? String(verified.videoBatchSize || '')\n        : null;\n    if (selected !== targetText) {\n      throw new CommandExecutionError(\n        `Could not verify Midjourney ${anchorText}: expected ${targetText}, found ${selected || 'unknown'}`,\n      );\n    }\n  }\n  return target.changed;\n}\n","sourceCodeStart":1412,"sourceCodeEnd":1448,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L1412-L1448","documentation":"CommandExecutionError from selectSiteSetting. The page-side evaluate that locates the anchor setting group and marks a matching candidate button returned { ok: false } (or nothing), so the setting could not be changed. The message includes the anchor (e.g. 'Model'), the desired target text, and the reason from the page script (e.g. 'X setting group not found').","triggerScenarios":"Calling selectSiteSetting(page, anchorText, candidates, targetText) when the anchor group (e.g. Model / Speed / Video Resolution / Video Batch Size) is absent from the settings panel, or none of the candidate labels matches a selectable option, or the target option is disabled.","commonSituations":"Setting label changed in Midjourney UI (candidates list out of date); settings panel not open — selectSiteSetting calls readSiteSettings first, which should throw earlier if the panel is broken; option exists but is disabled for the account tier; typo in targetText casing.","solutions":["Confirm the settings panel is open and shows the anchor group; re-open via toggleSettingsPanel and retry","Match targetText casing exactly to the candidate list (e.g. 'HD', 'Turbo', 'Raw')","Update the CLI/candidate labels to the current Midjourney option names","Read the target?.reason in the message to see whether the group or just the option was not found"],"exampleFix":"// before\nawait selectSiteSetting(page, 'Speed', ['Relax', 'Fast', 'Turbo'], 'turbo');\n// after\nawait selectSiteSetting(page, 'Speed', ['Relax', 'Fast', 'Turbo'], 'Turbo'); // casing must match an enabled candidate","handlingStrategy":"validation","validationCode":"const ALLOWED = { Speed: ['Relax','Fast','Turbo'], 'Video Resolution': ['SD','HD'], 'Video Batch Size': ['1','2','4'] };\nif (!ALLOWED[anchorText]?.includes(targetText)) throw new Error(`Unsupported ${anchorText} target: ${targetText}`);","typeGuard":null,"tryCatchPattern":"try {\n  await selectSiteSetting(page, anchor, candidates, target);\n} catch (e) {\n  if (String(e.message).includes('Could not set Midjourney')) {\n    console.error('Check panel is open and target casing matches candidates:', e.message);\n  }\n  throw e;\n}","preventionTips":["Pass targetText with exact candidate casing (e.g. 'Turbo', 'HD')","Ensure the settings panel is open and the anchor group visible","Check the reason embedded in the message (group vs option not found)","Update candidate lists when Midjourney renames options"],"tags":["browser-automation","dom-selector","midjourney","settings"],"backgroundTag":"dom-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}