{"record":{"id":"c561a9f474d7df3a","repo":"jackwener/OpenCLI","slug":"midjourney-settings-panel-returned-an-unexpected-s","errorCode":null,"errorMessage":"Midjourney settings panel returned an unexpected shape","messagePattern":"Midjourney settings panel returned an unexpected shape","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":1392,"sourceCode":"      if (menu && /^\\d+(?:\\.\\d+)?$/.test(menu.textContent?.trim() || '')) {\n        version = menu.textContent.trim();\n        break;\n      }\n    }\n    const imageResolution = selectedNear('Version', ['Standard', 'HD']);\n    const personalization = selectedNear('Personalize', ['On', 'Off']);\n    const raw = selectedNear('Raw', ['Standard', 'Raw']);\n    return {\n      model: version ? `v${version}` : null,\n      imageResolution: imageResolution ? imageResolution.toLowerCase().replace('standard', 'sd') : null,\n      personalization: personalization ? personalization === 'On' : null,\n      raw: raw ? raw === 'Raw' : null,\n      speed: (selectedNear('Speed', ['Relax', 'Fast', 'Turbo']) || '').toLowerCase() || null,\n      videoResolution: (selectedNear('Video Resolution', ['SD', 'HD']) || '').toLowerCase() || null,\n      videoBatchSize: Number(selectedNear('Video Batch Size', ['1', '2', '4'])) || null,\n    };\n  }));\n  if (!result || typeof result !== 'object') throw new CommandExecutionError('Midjourney settings panel returned an unexpected shape');\n  const missing = ['model', 'imageResolution', 'speed'].filter((key) => result[key] == null);\n  if (missing.length) {\n    throw new CommandExecutionError(`Midjourney settings panel is missing required field(s): ${missing.join(', ')}`);\n  }\n  return result;\n}\n\nexport async function selectSiteSetting(page, anchorText, candidates, targetText) {\n  await readSiteSettings(page);\n  const target = unwrapEvaluateResult(await page.evaluate((anchorLabel, values, wanted) => {\n    const visible = (element) => {\n      const rect = element.getBoundingClientRect();\n      return rect.width > 0 && rect.height > 0 && getComputedStyle(element).display !== 'none';\n    };\n    document.querySelectorAll('[data-opencli-setting-target]').forEach((node) => node.removeAttribute('data-opencli-setting-target'));\n    const anchors = [...document.querySelectorAll('h2,a,div,span')]\n      .filter((node) => node.textContent?.trim() === anchorLabel && visible(node))\n      .sort((left, right) => left.children.length - right.children.length);","sourceCodeStart":1374,"sourceCodeEnd":1410,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L1374-L1410","documentation":"CommandExecutionError from readSiteSettings. After opening the settings panel it evaluates the DOM to build a settings object (model, imageResolution, speed, raw, speed, videoResolution, videoBatchSize); if the evaluation returns null or a non-object the shape is unexpected and it throws before the required-field check.","triggerScenarios":"Calling readSiteSettings (directly or via selectSiteSetting) when the settings panel is not visible or its DOM did not yield the expected structure, so the evaluate callback returns null/undefined.","commonSituations":"Settings panel failed to open (toggle silently failed); Midjourney settings markup changed; page.evaluate wrapper returning an unwrapped null; navigation/rerender mid-read.","solutions":["Call isSettingsPanelVisible first and open the panel via toggleSettingsPanel before reading","Increase the wait after opening the panel so settings render","Update the CLI to match current settings panel DOM","Log the raw evaluate result to diagnose the shape mismatch"],"exampleFix":"// before\nconst settings = await readSiteSettings(page);\n// after\nif (!(await isSettingsPanelVisible(page))) {\n  await toggleSettingsPanel(page);\n  await page.wait(0.5);\n}\nconst settings = await readSiteSettings(page);","handlingStrategy":"validation","validationCode":"if (!(await isSettingsPanelVisible(page))) {\n  await toggleSettingsPanel(page);\n  await page.wait(0.5);\n}","typeGuard":"const isSettingsShape = (r) => r != null && typeof r === 'object';","tryCatchPattern":"try {\n  const settings = await readSiteSettings(page);\n} catch (e) {\n  if (String(e.message).includes('unexpected shape')) {\n    await toggleSettingsPanel(page); await page.wait(1);\n    return readSiteSettings(page);\n  }\n  throw e;\n}","preventionTips":["Always open/verify the settings panel before reading","Wait after opening so the panel fully renders","Re-read after any navigation or re-render","Update CLI when settings DOM changes"],"tags":["browser-automation","dom-selector","midjourney","schema-validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}